Debug Logics (Experimental Feature)
This feature was removed in Pricefx Studio 8.1.
How it Works
Formula elements are executed by a simplified formula engine in Pricefx Studio, similarly to the one running on the Pricefx backend server. The local calculation engine mimics the server one and it executes the elements sequentially as ordinary Groovy scripts and the idea is that each of the Pricefx Groovy API is implemented as a separate stateless call of the backend server.
Limitations
- This functionality is only experimental. It supports only a very limited scope of API and since it cannot cover 100% cases, the development has been put on hold and is not supported.
- Due to the implementation, not all of the API functions are supported and it is not guaranteed that the results will be the identical to the standard formula test feature.
- Only logics with all elements of the Groovy type are supported.
Prerequisites
For the project in IDEA you need to:
- Add Framework Support for Pricefx – see Upgrade Studio Project Libraries.
- Keep the element names unique within the project as described in Naming Conventions, otherwise you have to do the following:
- If you have some directories marked as "Source", remove such assignment in Module Settings > Modules > Sources (i.e. no directory should be marked as "Source"), except the /src directory.
- You may be asked to set the Output Path in Module Settings > Modules > Paths when running the debug for the first time.
Debug Logic
- Select parameters for the debug run as described here. You need to save the parameters into a file, since the filename will be passed to the launched debugger process as a parameter.
- Put the breakpoint at the last line of the src/debug.groovy script. This script file will be created automatically when you run the debugging for the first time.
- Open the desired element file(s) and add breakpoint(s) on the lines where you want to stop the formula execution.
- Click the 'Debug' button in the Logic editor. This starts the standard IDEA debugging of the debug.groovy script which will be automatically created in the src/ folder.
- When the debugger stops here, add the desired variables into Watches.
Hints for Variable Watches
Here are some tips for useful watches available from the element Groovy script:
api.ctx.orderedResultElements
– Shows all elements results.api
– Shows the result value of any element from your logic..ctx
.resultElements.get("<SOME_ELEMENT_NAME>").elementResultapi
– Shows details (such as api.traces, warnings etc.) of a certain element from your logic..ctx
.resultElements.get("<SOME_ELEMENT_NAME>")api.local
– Shows content of theapi.local
map.api.global
– Shows content of theapi.global
map.
Analogically, some of the watches are available in debug.groovy as:
engine.ctx.orderedResultElements
engine.ctx.resultElements.get("<SOME_ELEMENT_NAME>").elementResult
engine.ctx.resultElements.get("<SOME_ELEMENT_NAME>")
Evaluate Expressions on the Fly
You can also evaluate some API methods online e.g. vLookup()
or api.find()
:
- Right click anywhere in the source code text of some element script and choose "Evaluate expression" (Alt+F8).
- Enter some expression there and press Enter.
Supported APIs
- Contexts: Product (P), PriceGrid items (PGI), PriceList (PLI)
- Groovy libraries: both lib and libs are supported (since version 5.3)
api.getElement()
api.targetDate()
api.product(), api.productExtension(), api.productCompetition(), api.productXRef()
api.currentItem()
api.global
,api.local maps,
getGlobal(),api.
putGlobal()api.
api.find()
, api.count
()api.vLookup()
api.trace()
api.input(),
api.userEntry(),api.stringUserEntry(),
integerUserEntry(),api.
decimalUserEntry(),api.
booleanUserEntry(),api.
dateUserEntry(),api.
timeUserEntry(),api.
dateTimeUserEntry(), api.option()api.
api.newMatrix() (except transpose() method)
api.criticalAlert(), api.redAlert(), api.yellowAlert()
api.jsonEncode, api.jsonDecode(), api.jsonDecodeList()
api.isSyntaxCheck()
– always returnsfalse
api.isDebugMode()
– returnstrue
api.isDistributedMode()
– always returnsfalse
api.getId()
api.calendar()
api.random(), api.uuid()
api.getMaxFindResultsLimit()
api.formatNumber()
api.abortCalculation()
api.getTimeZone()
api.filter
,
api.filterFromMap()
api.user(), api.roles(),
api.isUserInGroup()
api.log(), api.logWarn(), api.logInfo()
api.pricelist()
api.pricelistItem()
api.getPricelistItem()
api.customer()
api.otherProduct()
api.productCompetition()
api.productXRef()
api.otherCustomer()
api.getCalculableLineItemCollection()
api.bom()
api.bomList()
api.findLookupTableValues()
api.getBoundPartitionNames()
api.contextByLabel()
api.findDataLoad()
api.findRebateRecordLoad()
api.attributedResult()
api.httpCall()
api.
boundCall()
Supported APIs with No Effect in Debug Mode
api.
add()api.
addOrUpdate()api.
update()api.
delete()api.
sendEmail()api.
createNewRevision()
What Will Not Be Supported
- Other than Groovy elements
- API functions which use other than basic Java types as input/output parameters (DatamartContext, ContextParameter)
- PA logics and Datamart context related
Best Practices for Logic Development with Debug Support
- Do not use the non-Groovy type of elements.
- Follow the Naming Conventions.
- Put if-else statements on multiple lines so you can place breakpoints and step in.
Found an issue in documentation? Write to us.