public interface PublicGroovyAPI
api
. That api
variable or binding is merely an instance of
this interface to expose certain "safe" methods and functionality.Modifier and Type | Method and Description |
---|---|
void |
abortCalculation()
Aborts the current item calculation.
|
Object |
add(String typeCode,
Map<String,Object> values)
Adds a new object to the collection of objects of the given type.
|
Object |
addOrUpdate(String typeCode,
Map<String,Object> values)
Adds or updates an object in the collection of objects of the given type.
|
void |
addWarning(String message)
Adds a warning to the formula execution warning log.
|
Object |
anyUser(String entryName)
Creates an input parameter that lets the user select a user from the list of all users.
|
AttributedResult |
attributedResult(Object result)
Creates an
AttributedResult object to be returned as a result of an output element. |
String |
base64Decode(String base64String)
Decodes a base64 encoded string.
|
String |
base64Encode(String string)
Provides a standard Base64 encoding of a string.
|
Object |
bom()
Accesses and retrieves values from a rolled-up bill of materials for the SKU being calculated.
|
Object |
bom(String lookupTableName)
Accesses and retrieves values from a rolled-up bill of materials for the SKU being calculated.
|
Object |
bom(String lookupTableName,
String categoryName)
Accesses and retrieves values from a rolled-up bill of materials for the SKU being calculated.
|
Object |
bom(String lookupTableName,
String categoryName,
String materialName)
Accesses and retrieves the values from a rolled-up bill of materials for the SKU being calculated
Only BoM records with the specified category and the material are considered.
|
Object |
bomList()
Rolls up the current SKU's BoM and returns the rolled up BoM records (not just the quantities).
|
Object |
booleanUserEntry(String entryName)
Creates an input parameter that lets the user enter a boolean (yes or no) value.
|
Object |
boundCall(String uniqueName,
String relativeUrl,
String body,
Boolean... responseBodyAsAString)
Triggers a HTTPS request towards the Price fx server, either local one or an external one.
|
ResultFlexChart |
buildFlexChart(Object definition)
Calls
buildFlexChart(null, definition)
See the full documentation in buildFlexChart(Object) . |
ResultFlexChart |
buildFlexChart(String baseTemplateToUse,
Object definition)
Creates a
FlexChart from the passed definition by
merging it with options defined within the
baseTemplateToUse template. |
ResultHighchart |
buildHighchart(Map<String,?> definition)
Creates a
ResultHighchart from the passed definition . |
ResultHighmap |
buildHighmap(Map<String,?> definition)
Creates a
ResultHighmap from the passed definition . |
Calendar |
calendar()
Gets a
java.util.Calendar object initialized with the current targetDate (or new Date() if no target date is given). |
Calendar |
calendar(Date date)
Gets a calendar object initialized with
date . |
Object |
configurator(String configuratorName,
String formulaName) |
Object |
configurator(String configuratorName,
String formulaName,
Object resultName) |
Object |
configurator(String configuratorName,
String formulaName,
Object width,
Object height) |
Object |
contextByLabel(String label)
Retrieves the previous calculation result by the logic element label (not the element result name).
|
String |
contextName()
The name of the current context, e.g.
|
Set<Object> |
contextSkuSet(int startRow)
Returns a set of SKUs which comprise so-called 'SKU context' of
the current formula execution.
|
String |
contextType()
The type (type code string) of the current context.
|
String |
contextTypedId()
The typedId of the current context.
|
int |
count(String typeCode,
Filter... filters)
Returns the number of records that a corresponding
find(String, int, int, String, List, Filter...) would return. |
ConfiguratorEntry |
createConfiguratorEntry()
Creates an empty configurator entry object.
|
ConfiguratorEntry |
createConfiguratorEntry(InputType type,
String name)
Creates a configurator entry object and adds the specified input parameter as the first parameter to the configurator entry.
|
ConfiguratorEntry |
createConfiguratorEntry(InputType type,
String name,
Date targetDate)
Creates a configurator entry object and adds the specified input parameter as the first parameter to the configurator entry.
|
ConfiguratorEntryArray |
createConfiguratorEntryArray(Object... entries)
Creates a configurator entry array object which is to be returned from
a logic element.
|
Filter |
createElementNameFilter(String elementName,
Object fieldValue,
String... listTypedIds)
Creates a cross-list filter expression based on meta data.
|
Object |
createNewRevision(String typedId)
Creates a revision of CalculableLineItemCollection (Quote, Rebate Agreement, Contract).
|
void |
criticalAlert(String msg)
Marks the current logic element as a critical alert and provides the given message.
|
Map<String,Object> |
currentContext(String sku)
In case of list processing (such as a price list or price grid), this method allows an easy access to values from the same list.
|
Map<String,Object> |
currentContext(String sku,
String key2)
In case of list processing (such as a price list or price grid), this method allows an easy access to values from the same list.
|
Object |
currentItem()
In case of a list processing operation, this method gets the currently worked on record (e.g., price list item or price grid item or quote item).
|
Object |
currentItem(String attributeName)
Same as
currentItem() but returns only the specified attribute. |
Object |
currentItemByElementName(String elementName)
In case of a list processing operation, this method gets the currently worked on record's property by elementName.
|
String |
currentPartitionName()
Returns the current partition name.
|
Object |
customer(String attributeName)
Retrieves the customer object for the SKU currently being calculated.
|
Object |
customer(String attributeName,
boolean defaultFromParent)
Equivalent of the standard syntax "Customer" function.
|
Object |
customer(String attributeName,
String customerId)
Retrieves the given attribute value from the customer table for the SKU being calculated.
|
Object |
customer(String attributeName,
String customerId,
boolean defaultFromParent)
Retrieves the given attribute value of the given customer.
|
Object |
customer(String attributeName,
String customerId,
boolean defaultFromParent,
String filterFormulaName,
Object filterFormulaParam)
Retrieves a named attribute value of the named customer (if the value is
null and defaultFromParent is true , retrieves (and returns) the value from the customer's
parent regardless if that value is null as well or not. |
Object |
customerExtension(String extensionName,
Filter... filters)
Retrieves a list of all customer extentions records (CX) from a CX table named
extensionName |
Object |
customerGroupEntry(String... entryName)
Creates an input parameter that lets the user select a group of customers and returns the selection as a Map.
|
Object |
customerGroupEntry(String entryName,
String filterFormulaName,
Object filterFormulaParam)
Creates an input parameter that lets the user select a group of customers and returns the selection as a Map.
|
Filter |
customerToRelatedObjectsFilter(String relatedObjectTypeCode,
String customerId)
Creates a filter to be applied to a search on a related object type, limiting the result to objects of the related type that have a link to the given customer.
|
void |
customEvent(Object object)
Sends an event of the type "CUSTOM".
|
void |
customEvent(Object object,
String customEventType)
Sends an event of the type "CUSTOM".
|
void |
customEvent(Object object,
String customEventType,
String operation)
Sends an event of the type "CUSTOM".
|
void |
customEvent(Object object,
String customEventType,
String operation,
boolean omitNullValues)
Sends an event of the type "CUSTOM".
|
Object |
datamartCalendar()
Deprecated.
Use
DatamartContext.calendar() instead. |
Filter |
datamartFilter(Object groupOrSlice)
Translates a CustomerGroup/ProductGroup/DMDataSlice to its equivalent filter representation,
mapping the domain level field names to the corresponding Datamart field names in the process.
|
Object |
datamartFilterBuilderUserEntry(String entryName,
String source,
Object... args)
Creates an input parameter that lets the user build a filter for a given Datamart.
|
Object |
datamartLookup(Object... queryAndProjectionsAndFilters)
Deprecated.
Use
DatamartContext.executeQuery(DatamartContext.Query) ,
net.pricefx.formulaengine.DatamartContext#executeSqlQuery(String, DatamartContext.Query...) or
DatamartContext.streamQuery(DatamartContext.Query) |
Object |
datamartQuery(Object... queryAndDatamartAndProjectionsAndFilters)
Deprecated.
|
Object |
dateRangeUserEntry(String entryName)
Creates an input parameter that lets the user enter a date range (start and end date).
|
Object |
dateTimeUserEntry(String entryName)
Creates an input parameter that lets the user to enter a date time value in format "dd/MM/yyyy HH:mm" (e.g.
|
Object |
dateUserEntry(String entryName)
Creates an input parameter that lets the user enter a date value.
|
Object |
decimalUserEntry(String entryName)
Creates an input parameter that lets the user enter a decimal value.
|
Object |
delete(String typeCode,
Map<String,Object> values)
Deletes an object in the collection of objects of the given type.
|
boolean |
emit(Object obj)
Emits an object to be consumed by an external thread.
|
boolean |
emitPersistedObject(String typedId)
Finds the PersistedObject with the given typedId and emits it if it exists.
|
boolean |
emitPersistedObject(String typeCode,
Long id)
Finds the PersistedObject for the given type and ID and emits it if it exists.
|
void |
emitRebateRecords(String dateFieldName,
String sortBy,
Filter... filters)
Emits the rebate records matching the given search criteria - to be consumed by a PA allocation task (a PA calculation task with a feeder formula calling
this method, and a regular formula accepting each emitted RebateRecord as its currentItem context, and distributing one or more RebateRecord accruals
over the set of PA rows which have contributed to those accruals in some way (by revenue, bvolume...).
|
String |
entityRef(PartitionedObject po)
Creates an entityRef value (usually db ID) for the given entity.
|
double |
evalExpression(String mathExpression)
Evaluates an arithmetic expression that is passed as a String.
|
Object |
filter(String property,
Object value)
Deprecated.
Use
Filter.equal(String, Object) instead |
Object |
filter(String property,
Object opString,
Object value)
Deprecated.
Use the
Filter functions instead |
Object |
filterBuilderUserEntry(String entryName,
String typeCode)
Creates an input parameter that lets the user build a filter for a table of objects of the type defined by
typeCode parameter. |
Filter |
filterFromMap(Map<String,Object> filterMap)
Constructs a Filter object from the map representation of that filter (from the "wire format").
|
List<Object> |
find(String typeCode,
Filter... filters)
Deprecated.
use
find(String, int, int, String, List, Filter...) in order to always specify the fields to be returned because of performance. |
List<Object> |
find(String typeCode,
int startRow,
Filter... filters)
Deprecated.
use
find(String, int, int, String, List, Filter...) because of performance you should always specify the fields to be returned. |
List<Object> |
find(String typeCode,
int startRow,
int maxRows,
String sortBy,
Filter... filters)
The Swiss army knife method of the API.
|
List<Object> |
find(String typeCode,
int startRow,
int maxRows,
String sortBy,
List<String> fields,
boolean distinctValuesOnly,
Filter... filters)
The Swiss army knife method of the API.
|
List<Object> |
find(String typeCode,
int startRow,
int maxRows,
String sortBy,
List<String> fields,
Filter... filters)
The Swiss army knife method of the API.
|
List<Object> |
find(String typeCode,
int startRow,
int maxRows,
String sortBy,
Map<String,String> fields,
boolean distinctValuesOnly,
Filter... filters)
The Swiss army knife method of the API.
|
List<Object> |
find(String typeCode,
int startRow,
String sortBy,
Filter... filters)
Deprecated.
use
find(String, int, int, String, List, Filter...) because of performance you should always specify the fields to be returned. |
List<SummaryCalculableObjectItem> |
findApprovedPricelistItems(String sku)
Returns a list of summary items.
|
List<CalculatedFieldSet> |
findCalculatedFieldSets(Date targetDate,
String cfsName)
Returns a list of calculated field sets that match the targetDate.
|
List<CustomerAssignment> |
findCustomerAssignments(String customerId)
Finds all assignment records for the given customerId.
|
List<Customer> |
findCustomersInGroup(CustomerGroup group)
Retrieves a list of customers that match the given CustomerGroup (returns first 200 entries).
|
List<Customer> |
findCustomersInGroup(CustomerGroup group,
int startRow,
String sortBy)
Retrieves a list of customers that match the given CustomerGroup with custom paging and sorting.
|
Object |
findDataLoad(String dataLoadLabel,
String dataLoadType,
String target) |
LookupTable |
findLookupTable(String tableName)
Finds a price parameter table object (LT) of the given name.
|
List<Object> |
findLookupTableValues(String tableName,
Filter... filters)
Returns all values of a named price parameter table (optionally filtered).
|
List<ManualPricelist> |
findManualPricelists(Date targetDate,
String listName)
Returns a list of manual price lists that match the targetDate (i.e.
|
Map<String,List<String>> |
findNextRevUNs(String typeCode,
String... uniqueNames)
Finds the next revision uniqueNames for the given Quotes/Contracts/RebateAgreements.
|
Map<String,Object> |
findPreviousApprovableState(String typedId,
String... workflowStatuses)
Finds the previous approvable entity state if some DENIED or WITHDRAWN workflow for the approvable exists.
|
WorkflowInfo |
findPreviousWorkflowInfo(String typedId,
String... workflowStatuses)
Finds the approvable entity previous workflow history if some DENIED or WITHDRAWN workflow for the approvable exists.
|
List<PriceGrid> |
findPriceGrids(Date targetDate,
String priceGridName)
Returns a list of price grids that match the targetDate (i.e.
|
List<Pricelist> |
findPricelists(Date targetDate,
String listName)
Returns a list of price lists that match the targetDate (i.e.
|
Object |
findRebateRecordLoad(String rebateRecordLoadLabel) |
List<Simulation> |
findSimulations(Date targetDate,
String simulationName)
Returns a list of simulations that match the targetDate (i.e.
|
WorkflowInfo |
findWorkflowInfo(String approvableTypeCode,
Object approvableId)
Finds active workflows for the given approvable.
|
String |
formatNumber(String pattern,
Object n)
Formats a number as a String.
|
String |
formatNumber(String locale,
String pattern,
Object n)
Formats a number as a String.
|
String |
formatString(String locale,
String format,
Object... args)
Formats a string like
String.format(java.lang.String, java.lang.Object...) . |
String |
getBaseURL()
Returns the base URL component of the current instance.
|
List<String[]> |
getBatchInfo()
Gets the info about the current batch of items being calculated by a calcuation thread.
|
Object |
getBinding(String name)
Gets a named binding variable from a library function.
|
Object |
getBoundPartitionNames()
Returns a bound partition list.
|
<T extends CalculableLineItem> |
getCalculableLineItem(Object clic,
String lineId)
Returns a line item of the given calculable line item collection (CLIC).
|
Object |
getCalculableLineItemCollection(String typedId)
Returns the full object (header and line items) of e.g.
|
Object |
getCalculableLineItemResult(Object cli,
String... resultNamesOrLabels)
Returns results of the given names (or labels) from a line item object (its map representation).
|
String |
getCalculationContext()
Retrieves the CalculationContext of the logic evaluation (logic element group).
|
ClaimContext |
getClaimContext()
Gives current item context in claim validation
|
DatamartContext |
getDatamartContext()
Provides an API for querying and loading PA data.
|
DatamartRowSet |
getDatamartRowSet()
Available in a PA DataLoad context only, a
DatamartRowSet provides access to the rows being loaded or calculated. |
DatamartRowSet |
getDatamartRowSet(String name)
Available in a PA DataLoad context only, a
DatamartRowSet provides access to the rows currently being loaded or calculated. |
Object |
getElement(String name)
Gets the result of the previous logic element.
|
Map<String,Object> |
getGlobal()
A publicly available cache (as a hashmap) for storing and sharing values across logic elements.
|
Long |
getId(Object obj)
Returns the ID part of an object.
|
Map<String,Object> |
getItemActiveCalculationResults(String typedId)
Gets the current complete active (i.e.
|
Map<String,Object> |
getItemCompleteCalculationResults(String typedId)
Gets the current complete calculation results of the given item (e.g., price list item).
|
int |
getIterationNumber()
Returns the number of iterations this list has been calculated during this cycle.
|
String |
getLocale()
Returns the language part of the current request's locale (e.g.
|
Object |
getManualOverride(String elementName)
Returns a user entered value that overrides the calculated result of a logic element.
|
int |
getMaxFindResultsLimit()
Returns the maximum number of records that
find(String, int, int, String, Filter...) and its variations can return in one call. |
ContextParameter |
getParameter(String parameterName)
Retrieves an already generated (in the previous logic step) input parameter in the form of a
ContextParameter object. |
ItemSummaryQuery<PriceGrid> |
getPriceGridSummaryQuery()
Creates a summary query object that can be parameterized and is then subsequently used in
runSummaryQuery(ItemSummaryQuery) . |
Map<String,Object> |
getPricelistItem(String listName)
Similar to the
pricelistItem(String) function. |
ItemSummaryQuery<Pricelist> |
getPricelistSummaryQuery()
Creates a summary query object that can be parameterized and is then subsequently used in
runSummaryQuery(ItemSummaryQuery) . |
List<?> |
getProductReferences(String typeCode,
Set<String> skus)
Returns a list of product reference records that tell which other objects, of the given type, reference these SKUs.
|
Object |
getProperty(Object object,
String path)
Serves as an optimized way to get to certain object attributes.
|
Object |
getPropertyByElementName(Object object,
String elementName)
Gets object attributes by elementName.
|
ItemSummaryQuery<RebateRecordSet> |
getRebateRecordSummaryQuery()
Creates a summary query object that can be parameterized and is then subsequently used in
runSummaryQuery(ItemSummaryQuery) . |
Object |
getSecondaryKey()
Same as
api.currentItem("key2") . |
String |
getSharedCache(String key)
Retrieves a value from the shared cache (and resets the TTL of the key).
|
ItemSummaryQuery<Simulation> |
getSimulationSummaryQuery()
Creates a summary query object that can be parameterized and is then subsequently used in
runSummaryQuery(ItemSummaryQuery) . |
TableContext |
getTableContext()
Provides an SQL query (SELECT only) interface to PA query results.
|
DateTimeZone |
getTimeZone(String tzString)
Provides a wrapper for org.joda.time.DateTimeZone.forId(String tzString) method.
|
Object |
httpCall(String url,
String body)
Issues an HTTP call to an external entity.
|
Object |
httpCall(String url,
String body,
String methodType,
String contentType,
Map... properties)
Issues an HTTP call to an external entity.
|
Object |
inlineConfigurator(String configuratorName,
String formulaName) |
Object |
input(String inputName)
Retrieves the value of the input parameter of the given name.
|
Object |
inputMatrix(String inputMatrixName,
Map<String,Object> paramConfig,
String... columns)
Creates an input parameter that lets the user select a matrix of values.
|
Object |
inputMatrix(String inputMatrixName,
String... columnNames)
Creates an input parameter that lets the user select a matrix of values.
|
Object |
integerUserEntry(String entryName)
Creates an input parameter that lets the user enter an integer value.
|
boolean |
isDebugMode()
Returns true if the logic is called via the UI debug/test execution mode.
|
boolean |
isDistributedMode()
Returns true if the calculation is executed in the distributed mode.
|
Boolean |
isFullListCalculation()
Indicates whether the current calculation is recalculating the entire list or only parts of it.
|
boolean |
isSecondPass()
Deprecated.
Use
getIterationNumber() > 0 instead. |
boolean |
isSyntaxCheck()
Returns true if the formula is executed in the syntax check mode.
|
boolean |
isUserInGroup(String userGroupName,
String loginUserName)
Checks if the current user is a member of the given user group.
|
Object |
jsonDecode(String json)
A utility method to decode a JSON string into a Map representation.
|
Object |
jsonDecodeList(String json)
A utility method to decode a JSON string into a List representation.
|
Object |
jsonEncode(Object input)
A utility method to encode an object to a JSON string.
|
Object |
jsonEncode(Object input,
boolean omitNull)
A utility method to encode an object to a JSON string.
|
void |
log(Object msg)
This function can be used by the support team only.
|
void |
log(String msg,
Object arg1)
This function is meant to be used by the Pricefx internally only.
|
void |
logInfo(Object msg)
Logs a INFO message to the system error log which can be displayed in menu Tools / Logs / View Log.
|
void |
logInfo(String msg,
Object arg1)
Logs an INFO warning message to the system error log which can be displayed in menu Tools / Logs / View Log.
|
void |
logWarn(Object msg)
Logs a WARN message to the system error log which can be displayed in menu Tools / Logs / View Log.
|
void |
logWarn(String msg,
Object arg1)
Logs a WARN message to the system error log which can be displayed in menu Tools / Logs / View Log.
|
void |
markItemClean()
Removes the dirty flag from the current item set previously by
markItemDirty() . |
void |
markItemClean(String sku)
Removes the dirty flag from the specified item set previously by
markItemDirty(String) . |
void |
markItemClean(String sku,
String key2)
Removes the dirty flag from the specified matrix item set previously by
markItemDirty(String, String) . |
void |
markItemDirty()
Sets the dirty flag on the specified item, i.e.
|
void |
markItemDirty(String sku)
Sets the dirty flag on the specified item, i.e.
|
void |
markItemDirty(String sku,
String key2)
Sets the dirty flag on the specified item, i.e.
|
MultiKey<Object> |
multiKey(Object... keys)
Constructs a new composite key object which can be used as a key in a map.
|
Object |
multiTierEntry(String entryName,
String... arguments)
Creates an input parameter that lets the user enter multiple discounts/surcharges/tiers by amount.
|
AdaptiveHistogram |
newAdaptiveHistogram()
Creates a histogram that adapts to an unknown data distribution.
|
DashboardController |
newController()
Creates a new dashboard controller object that can be further customized.
|
CreationWorkflowDefinition |
newCreationWorkflow() |
CreationWorkflowStepDefinition |
newCreationWorkflowStep() |
Object |
newDatamartSlice()
Deprecated.
Use
DatamartContext.newDatamartSlice() instead. |
Object |
newDatamartSlice(String dateFieldName,
Object... timePeriodsAndProductAndCustomerGroups)
Deprecated.
Use
DatamartContext.newDatamartSlice(String, Object...) instead. |
ResultGauge |
newGauge()
Creates a new gauge object that can be further customized.
|
ResultMatrix |
newMatrix()
Creates a new result matrix DTO object that can be further customized and populated with calculated data.
|
ResultMatrix |
newMatrix(Collection<String> columns)
Creates a new result matrix DTO object that can be further customized and populated with calculated data.
|
ResultMatrix |
newMatrix(String... columns)
Creates a new result matrix DTO object that can be further customized and populated with calculated data.
|
Object |
option(String entryName,
List<Object> options,
Map<String,Object> labels)
Creates an input parameter that lets the user select a single value from the predefined options.
|
Object |
option(String entryName,
Object... options)
Creates an input parameter that lets the user select a single value from the predefined options.
|
Object |
options(String entryName,
List<Object> options,
Map<String,Object> labels)
Creates an input parameter that lets the user select multiple values from the predefined options.
|
Object |
options(String entryName,
Object... options)
Creates an input parameter that lets the user select multiple values from the predefined options.
|
Object |
otherCustomer(String parameterName)
Triggers a custom-named customer picker input parameter.
|
Object |
otherCustomer(String parameterName,
String attributeName)
Triggers a custom-named customer picker input parameter.
|
Object |
otherCustomer(String parameterName,
String attributeName,
boolean defaultFromParent)
Triggers a custom-named customer picker input parameter.
|
Object |
otherProduct(String parameterName)
Triggers a custom-named product picker input parameter.
|
Object |
otherProduct(String parameterName,
String attributeName)
Triggers a custom-named product picker input parameter.
|
Object |
parsableInputFile(String inputName)
Creates an input parameter that lets the user pick a file.
|
Object |
parsableInputFileData(String inputName)
If a parsableInputFile has a value, this function opens the file and parses it to basic Groovy data structures.
|
Object |
parsableInputFileDataFromHandle(String fileHandle)
If a parsableInputFile has a value, this function opens the file and parses it to basic groovy datastructures.
|
Date |
parseDate(String pattern,
String date)
Parses a date (entered as a String) according to the given pattern.
|
DateTime |
parseDateTime(String pattern,
String datetime)
Parses a datetime (entered as a String) according to the given pattern.
|
DateTime |
parseDateTime(String pattern,
String datetime,
int tzHoursOffset,
int tzMinutesOffset)
Parses a datetime (entered as a String) according to a given pattern and time zone.
|
Map<String,Object> |
previousContext(String sku)
In case of (chained) price lists, this method allows for an easy retrieval of records from the previous list.
|
Map<String,Object> |
previousContext(String sku,
String key2)
In case of (chained) price lists, this method allows for an easy retrieval of records from the previous list.
|
Object |
pricelist(String listName)
Looks up the result price (considering a manual override) of an SKU being calculated in a price list of the given name.
|
Object |
pricelist(String listName,
String attributeName)
Looks up the attribute defined by
attributeName (considering a manual override) of an SKU being calculated in a price list of the given name. |
Object |
pricelist(String listName,
String attributeName,
String sku)
Looks up the result price (considering a manual override) of a given SKU in a price list of the given name.
|
Object |
pricelist(String listName,
String attributeName,
String sku,
String key2)
Looks up the attribute defined by
attributeName (considering a manual override) of the given SKU in a matrix price list of the given name. |
Object |
pricelistItem(String listName)
Looks up the price list item record (PLI or XPLI) of an SKU being calculated in a price list of the given name.
|
Object |
pricelistItem(String listName,
String sku)
Looks up the price list item record (PLI) of the given SKU in a price list of a given name.
|
Object |
pricelistItem(String listName,
String sku,
String key2)
Looks up the matrix price list item record (XPLI) of the given SKU in a matrix price list of the given name.
|
Object |
product()
Retrieves the product object for the SKU currently being calculated.
|
Object |
product(String attributeName)
Retrieves the given attribute value from the product table for the SKU being calculated.
|
Object |
product(String attributeName,
String sku)
Retrieves the given attribute value from the product table for a given SKU.
|
Object |
product(String attributeName,
String sku,
String filterFormulaName,
Object filterFormulaParam)
Retrieves the given attribute value from the product table for a given SKU.
|
Object |
productCompetition()
Retrieves a list of all product competition records (PCOMP) for the SKU being calculated.
|
Object |
productCompetition(Filter... filters)
Retrieves a list of product competition records (PCOMP) for the SKU being calculated filtered by
filters . |
Object |
productExtension(String extensionName)
Retrieves a list of all product extentions records (PX) from a PX table named
extensionName for the SKU being calculated. |
Object |
productExtension(String extensionName,
Filter... filters)
Retrieves a list of product extentions records (PX) from a PX table named
extensionName for the SKU being calculated filtered by filters . |
Object |
productGroupEntry(String... entryName)
Creates an input parameter that lets the user select a group of products and returns the selection as a Map.
|
Object |
productGroupEntry(String entryName,
String filterFormulaName,
Object filterFormulaParam)
Creates an input parameter that lets the user select a group of products and returns the selection as a Map.
|
Filter |
productToRelatedObjectsFilter(String relatedObjectTypeCode,
String sku)
Creates a filter to be applied to a search on a related object type, limiting the result to objects of the related type that have a link to the given product.
|
Object |
productXRef()
Retrieves a list of all product reference records (PXREF) for the SKU being calculated.
|
Object |
productXRef(Filter... filters)
Retrieves a list of all product reference records (PXREF) for the SKU being calculated.
|
void |
putGlobal(Map<String,Object> globalVars)
Puts an entire map of variables into the global cache.
|
Random |
random()
Provides the access to the standard
java.util.Random generator instance created for the duration of the calculation task
(= not get recreated for each logic element evaluation). |
Object |
rebateAgreementUserEntry(String parameterName,
String attributeName)
Prompts the user to input parameters for a rebate agreement (RBA).
|
void |
redAlert(String msg)
Marks the current logic element with a red alert and provides the given message.
|
Filter |
relatedObjectToCustomersFilter(String relatedObjectTypedId)
Creates a filter to be applied to a customer search, limiting the result to customers that are linked to the given related object, the latter defined by its typedId.
|
Filter |
relatedObjectToProductsFilter(String relatedObjectTypedId)
Creates a filter to be applied to a product search, limiting the result to products that are linked to the given related object, the latter defined by its typedId.
|
void |
removeManualOverride(String elementName)
Removes a user entered value that overrides the calculated result of a logic element.
|
void |
removeSharedCache(String key)
Deletes a key from the shared cache.
|
void |
resetSKUContextSwitch()
Resets a SKU context switch to the originally specified SKU.
|
Map<String,String> |
roles()
Lists all roles available in the application.
|
List<Map<String,Object>> |
runSummaryQuery(ItemSummaryQuery<? extends CalculableObject> query)
Runs (executes) a summary query defined by the parameterized query object which was created by one of the getXXXSummaryQuery calls.
|
void |
sendEmail(String to,
String subject,
String message)
Sends an email.
|
void |
setAlertMessage(String msg)
Marks the current formula element with the given alert message.
|
void |
setSharedCache(String key,
String value)
Stores a string value in the shared cache with the given key.
|
AbstractProducer.ResultIterator |
stream(String typeCode,
String sortBy,
Filter... filters)
Searches for all types of objects with a freestyle query and iterates over the result set.
|
AbstractProducer.ResultIterator |
stream(String typeCode,
String sortBy,
List<String> fields,
boolean distinctValuesOnly,
Filter... filters)
Searches for all types of objects with a freestyle query and iterates over the result set.
|
AbstractProducer.ResultIterator |
stream(String typeCode,
String sortBy,
List<String> fields,
Filter... filters)
Searches for all types of objects with a freestyle query and iterates over the result set.
|
AbstractProducer.ResultIterator |
stream(String typeCode,
String sortBy,
Map<String,String> fields,
boolean distinctValuesOnly,
Filter... filters)
Searches for all types of objects with a freestyle query and iterates over the result set.
|
Object |
stringUserEntry(String entryName)
Creates an input parameter that lets the user enter a short text value.
|
Object |
stringUserEntry(String entryName,
String textMask)
Creates an input parameter that lets the user enter a short text value.
|
Object |
stringUserEntry(String entryName,
String textMask,
String label)
Creates an input parameter that lets the user enter a short text value.
|
void |
switchSKUContext(String newSKU)
Temporarily switches the current SKU context to another SKU.
|
Date |
targetDate()
Retrieves the mandatory parameter targetDate from the current execution context.
|
Object |
textUserEntry(String entryName)
Creates an input parameter that lets the user enter a longer text value.
|
Object |
textUserEntry(String entryName,
String label)
Creates an input parameter that lets the user enter a longer text value.
|
void |
throwException(String errorMessage)
Throws a calculation exception with the specified message and aborts the calculation.
|
Object |
timeUserEntry(String entryName)
Creates an input parameter that lets the user to enter a time value in format "HH:mm" (e.g.
|
void |
trace(Object result)
Generates a trace message that can be used in the logic test drive.
|
void |
trace(String functionName,
Object result)
Generates a trace message that can be used in the logic test drive.
|
void |
trace(String functionName,
String parameters,
Object result)
Generates a trace message that can be used in the logic test drive.
|
Long |
triggerCFSCalculation(Long cfsID)
Creates a new background calculation job for the specified CFS.
|
Long |
triggerPriceGridCalculation(Long priceGridId,
Map<String,Object> parameters)
Creates a new background calculation job for the specified price grid.
|
Object |
update(String typeCode,
Map<String,Object> values)
Updates an object in the collection of objects of the given type.
|
Object |
updateCalculableObjectHeader(String calcObjTypeCode,
String calcObjName)
Updates the header information of a CalculableObject (e.g., a price grid, a price list, etc.).
|
Object |
user()
Returns the entire master data object of the current user.
|
Object |
user(String attributeName)
Returns a value from the current user's master data.
|
Object |
userEntry(String entryName)
Triggers a numeric input element.
|
String |
uuid()
Generates a RFC4122, version 4 ID.
|
String |
uuid(int len)
Generates a random uuid of the specified length.
|
String |
uuid(int len,
int radix)
Generates a random uuid of the specified length and radix.
|
Object |
vLookup(String parameterName)
Searches for a record in the price parameter table named
parameterName
where the column 'name' matches the value
entered by the user and returns the value from the column 'value'. |
Object |
vLookup(String parameterName,
Object attributeNameOrKeyOrRangeValue)
Searches for a record in the price parameter table named
parameterName
where the column 'name' (for LTV or MLTV) or 'key1' (for MLTV2-6)
matches the attributeNameOrKeyOrRangeValue value
and returns the value from the column 'value' (LTV) or 'attribute1' (MLTV). |
Object |
vLookup(String parameterName,
String attributeName,
String key)
This syntax is only relevant for MATRIX 1-key price parameter tables (MLTV).
|
Object |
vLookup(String parameterName,
String attributeName,
String key1,
String key2)
This syntax is only relevant for MATRIX 2-key price parameter tables (MLTV2).
|
Object |
vLookup(String parameterName,
String attributeName,
String key1,
String key2,
String key3)
This syntax is only relevant for MATRIX 3-key price parameter tables (MLTV3).
|
Object |
vLookup(String parameterName,
String attributeName,
String key1,
String key2,
String key3,
String key4)
This syntax is only relevant for MATRIX 4-key price parameter tables (MLTV4).
|
Object |
vLookup(String parameterName,
String attributeName,
String key1,
String key2,
String key3,
String key4,
String key5)
This syntax is only relevant for MATRIX 5-key price parameter tables (MLTV5).
|
Object |
vLookup(String parameterName,
String attributeName,
String key1,
String key2,
String key3,
String key4,
String key5,
String key6)
This syntax is only relevant for MATRIX 6-key price parameter tables (MLTV6).
|
Filter |
walkFilter(Filter filter,
Closure<?> visitBefore,
Closure<?> visitAfter,
boolean removeNulls)
Walks a filter and all its sub filters, visiting each filter in the tree.
|
WrappedResult |
wrap(Object result)
Wraps a result to make sure the original result object appears in the JSON response.
|
void |
yellowAlert(String msg)
Marks the current logic element with a yellow alert and provides the given message.
|
boolean isSyntaxCheck()
product()
or currentItem()
as well as getElement(String)
) produce null or mocked values.
Note: The best practise is to gather all parameters in the first elements of the logic and then abort the calculation after all parameters are gathered, otherwise all code which depends on the item data will need a special treatment (it would have to be surrounded using this function).
Example:
Element Amount:
Element Comment:return api.decimalUserEntry("Amount")
Element SyntaxCheckAbort:return api.stringUserEntry("Comment")
if (api.isSyntaxCheck()) { api.abortCalculation() }
boolean isDebugMode()
boolean isDistributedMode()
Map<String,Object> getGlobal()
api.retainGlobal
is set to true, this map will also be available with the entire list calculation,
i.e across item boundaries. It can be also accessed directly as api.global
.
Important: This map must be treated as a cache.
It means that the logic should never rely on the cached values, as in various situations this cache is purged
or structured differently. For example, in a distributed calculation, every calculation thread has its own cache;
or in a multi-pass list calculation, the subsequent passes may not have the cache of the previous pass available.
The system always tries to make it available, but the logic should never rely on it.void putGlobal(Map<String,Object> globalVars)
globalVars
- The map of variables to put into the global cacheString getCalculationContext()
List<String[]> getBatchInfo()
Long getId(Object obj)
obj
- The given object (Map)Object getElement(String name)
Note: from El presidente release, there should be no need to use this function anymore, since the values from previous elements are injected as variables with the name equal to element name just with the first letter in lowercase. Works only if the element name starts with a Capital (e.g. SomeElement and not someElement).
name
- The name of the logic elementnull
if the element is not foundObject getSecondaryKey()
api.currentItem("key2")
. Retrieves the secondary key (field "key2") of a matrix item record. Applicable in the following contexts:
null
if calculating a single item record (= not a matrix item record from the list above)Object getBinding(String name)
In a workflow formula, the workflow can be referenced in a Groovy element directly by the binding/variable "workflow":
workflow.addApprovalStep("First Approval")
However, this does not work from a library function as this script does not have the binding available. You need to use:
api.getBinding("workflow").addApprovalStep("First Approval")
name
- The name of the variableDate targetDate()
new Date()
by default or overriden in:
Calendar calendar()
java.util.Calendar
object initialized with the current targetDate (or new Date() if no target date is given).
Used for adding days/months/year and/or setting hours, minutes, seconds.
Example:
def months = 6 def calendar = api.calendar() // adds months to the date calendar.add(Calendar.MONTH, months) calendar.set(Calendar.HOUR_OF_DAY, startHour) calendar.set(Calendar.MINUTE, 0) calendar.set(Calendar.SECOND, 0) // return the date 6 months later after targetDate at 00:00:00 calendar.getTime()
Calendar calendar(Date date)
date
.
Example:
def months = 6 def targetDate = api.targetDate() def calendar = api.calendar(targetDate) // adds months to the date calendar.add(Calendar.MONTH, months) calendar.set(Calendar.HOUR_OF_DAY, startHour) calendar.set(Calendar.MINUTE, 0) calendar.set(Calendar.SECOND, 0) // return the date 6 months later after the given date at 00:00:00 calendar.getTime()
date
- The date to initialize the calendar withRandom random()
java.util.Random
generator instance created for the duration of the calculation task
(= not get recreated for each logic element evaluation).
Example 1:
def randomPct = (90 + api.random().nextInt(20)) / 100 // randomPct contains the random Integer number between 90 (inclusive) and 110 (exclusive)
Example 2:
def random = api.random().nextLong() // random contains the random Long number e.g. -2249116201139970752
java.util.Random
generator instance created for the duration of the calculation task
(i.e. does not get re-created for each formula (element) evaluation).Object datamartCalendar()
DatamartContext.calendar()
instead.DatamartCalendar
object.@Deprecated Object newDatamartSlice()
DatamartContext.newDatamartSlice()
instead.DatamartContext.DataSlice
objectObject newDatamartSlice(String dateFieldName, Object... timePeriodsAndProductAndCustomerGroups)
DatamartContext.newDatamartSlice(String, Object...)
instead.dateFieldName
- Name of the time dimension fieldtimePeriodsAndProductAndCustomerGroups
- TimePeriod, CustomerGroup, ProductGroup filtersDatamartContext.DataSlice
objectFilter datamartFilter(Object groupOrSlice)
Note: A DMDataSlice object can be instantiated by api.newDatamartSlice, or in a Rebate calculation context, referenced by the 'calulationBase' binding.
def filter = api.customerGroupEntry("Customer Filter") return filter != null ? api.datamartFilter(filter) : Filter.custom("1=1")
groupOrSlice
- The CustomerGroup/ProductGroup/DMDataSlice to translate into Datamart level filter criteriaObject datamartQuery(Object... queryAndDatamartAndProjectionsAndFilters)
DatamartContext.newQuery(Table)
DatamartContext
).
Runs a query against a PA Datamart. The query is only executed once in the scope of a calculation job (PL generation etc.).
The query is identified by the first argument. This is also the 'handle' by which datamartLookup refers to the result set of the query.queryAndDatamartAndProjectionsAndFilters
- The first argument is the query ID/handle, subsequent arguments are either DM field names (projections)
or filter objects.Object datamartLookup(Object... queryAndProjectionsAndFilters)
DatamartContext.executeQuery(DatamartContext.Query)
,
net.pricefx.formulaengine.DatamartContext#executeSqlQuery(String, DatamartContext.Query...)
or
DatamartContext.streamQuery(DatamartContext.Query)
DatamartContext
).
Looks up rows in the result of a datamartQuery(...) call.queryAndProjectionsAndFilters
- The first arguments is the ID/handle from a datamartQuery(...) call. Subsequent arguments refer to
projections specified in the datamartQuery call or filter objects leading to additional filtering of rows in the result set.DatamartContext getDatamartContext()
DatamartContext.getDatamart(String)
to be further queriedDatamartContext.getDataSource(String)
to be further queriedDatamartContext.calendar()
Example 1:
def ctx = api.getDatamartContext() def dm = ctx.getDatamart("Transactions_DM") def query = ctx.newQuery(dm, true) .select("ProductGroup") .select("SUM(SalesValue)") .where( Filter.equal("Year", "2019"), ) .groupBy("ProductGroup") .orderBy("ProductGroup") def result = ctx.executeQuery(query) return result?.getData()
Example 2:
def date = api.parseDate("yyyy-MM-dd", "2018-01-24") def week = api.getDatamartContext().calendar().getWeek(date) return week
DatamartContext
TableContext getTableContext() throws Exception
TableContext
Exception
- if a DB connection cannot be establishedDatamartRowSet getDatamartRowSet()
DatamartRowSet
provides access to the rows being loaded or calculated.DatamartRowSet
holding the data rows to load in the target FC.DatamartRowSet getDatamartRowSet(String name)
DatamartRowSet
provides access to the rows currently being loaded or calculated.
The following Data Load types make use of rowsets:
Example 1:
def newRow = [ "sku" : "1234456", "cost" : 123 ] def target = api.getDatamartRowSet("target") // target is null when running the logic test execute, so you can use trace for debugging purposes if (target) { target.addRow(newRow) } else { api.trace("newRow", null, newRow) }
Example 2:
def source = api.getDatamartRowSet("source") def target = api.getDatamartRowSet("target") while (source?.next()) { def row = source?.getCurrentRow() // perform the required calculation of row target["TotalSales"] = ... // target is null when running the logic test execute, so you can use trace for debugging purposes if (target) { target.addRow(row) } }
name
- Either 'source' to select the source FC or 'target' to select the target FC rowset.DatamartRowSet
holding either the source or target rowset.getDatamartContext()
,
DatamartContext.newQuery(Table)
void switchSKUContext(String newSKU)
product()
productCompetition()
productExtension(String)
productXRef()
bom()
bomList()
pricelist(String)
getPricelistItem(String)
resetSKUContextSwitch()
or automatically at the beginning of every element.
Example:
def masterSku = api.productXRef() def costs if (masterSku) { api.switchSKUContext(masterSku[0].targetSku) // take the cost from the masterSku item costs = api.productExtension("Cost") api.resetSKUContextSwitch() } else { // take the cost from the item being calculated costs = api.productExtension("Cost") } if (costs) { .... }
newSKU
- The new SKU to switch to.resetSKUContextSwitch()
,
product(String, String)
void resetSKUContextSwitch()
switchSKUContext(String)
Object product()
Example:
def item = api.product() def message = checkItem(item) def checkItem(item) { if (!item.attribute2) { // Product group return "Product group not set" } else if (!item.attribute5) { // Manufacturer return "Manufacturer not set" } }
currentItem()
Object product(String attributeName)
Example:
def label = api.product("label") def productGroup = api.product("attribute1") // Product Group def manufacturer = api.product("attribute4") // Manufacturer
attributeName
- The attribute value to be returnedcurrentItem(String)
Object product(String attributeName, String sku)
Example:
def masterSku = ... def label if (masterSku) { // take the label from the masterSku item label = api.product("label", masterSku) } else { // take label from the item being calculated label = api.product("label") }
attributeName
- The attribute whose value should be returnedsku
- The productnull
if product not found)Object product(String attributeName, String sku, String filterFormulaName, Object filterFormulaParam)
attributeName
- The attribute whose value should be returnedsku
- The productfilterFormulaName
- Unique name of a formula that will be triggered when the Product picker opensfilterFormulaParam
- Additional data for filterFormulanull
if product not found)Object otherProduct(String parameterName, String attributeName)
parameterName
- The name of the parameterattributeName
- The attribute whose value should be returned (null
for the entire object)Object otherProduct(String parameterName)
parameterName
- The name of the parameterObject productExtension(String extensionName)
extensionName
for the SKU being calculated.
Consider use of getBatchInfo()
for the performance reasons.
Example:
def promotions = api.productExtension("Promotion") if (promotions) { def promotion = promotions.getAt(0) ... }
extensionName
- The name of the extensiongetBatchInfo()
Object productExtension(String extensionName, Filter... filters)
extensionName
for the SKU being calculated filtered by filters
.
Consider use of getBatchInfo()
for the performance reasons.
Example:
def filter = [ Filter.greaterOrEqual("attribute1", targetDate), // Valid from Filter.lessOrEqual("attribute2", targetDate) // Valid to ] def promotions = api.productExtension("Promotion", *filter) if (promotions) { def promotion = promotions.getAt(0) ... }
extensionName
- The name of the extensionfilters
- One or more Filter
objects that narrow down the searchgetBatchInfo()
Object productCompetition()
productExtension(String)
instead since that gives you a better flexibility.getBatchInfo()
Object productCompetition(Filter... filters)
filters
.
Consider using productExtension(String)
instead since that gives you a better flexibility.filters
- One or more Filter
objects that narrow down the searchObject productXRef()
getBatchInfo()
for the performance reasons.getBatchInfo()
Object rebateAgreementUserEntry(String parameterName, String attributeName)
parameterName
- - The name of an entry in the input parameters listing (mandatory)attributeName
- - The name of the attribute you need (mandatory)null
if RA does not existsObject productXRef(Filter... filters)
filters
- One or more Filter
objects that narrow down the PXREF searchgetBatchInfo()
Object customer(String attributeName)
attributeName
- The attribute value to be returnedObject customer(String attributeName, boolean defaultFromParent)
null
and defaultFromParent is true
, it retrieves (and returns) the value from
the customer's parent regardless if that value is null
as well or not. If there is no parent customer set,
null
will be returned.attributeName
- The attribute value to be returneddefaultFromParent
- Determines whether to look up the value from the parent customer (if any) in case it is null
in the customerObject customer(String attributeName, String customerId)
attributeName
- The attribute value to be returnedcustomerId
- The customerId value for the customer searchnull
if no customer found)Object customer(String attributeName, String customerId, boolean defaultFromParent)
null
and defaultFromParent is true
, it retrieves (and returns) the value from the customer's
parent regardless if that value is null
as well or not. If there is no parent customer set, null
will be returned.attributeName
- The attribute value to be returnedcustomerId
- The customerId value for the customer searchdefaultFromParent
- Determines whether to look up the value from the parent customer (if any) in case it is null
in the customernull
if no customer found)Object customer(String attributeName, String customerId, boolean defaultFromParent, String filterFormulaName, Object filterFormulaParam)
null
and defaultFromParent is true
, retrieves (and returns) the value from the customer's
parent regardless if that value is null
as well or not. If there is no parent customer set, null
will be returned)attributeName
- The attribute value to be returnedcustomerId
- The customerId value for the customer searchdefaultFromParent
- Determines whether to look up the value from the parent customer (if any) in case it is null
in the customerfilterFormulaName
- Unique name of a formula that will be triggered when the Customer picker opensfilterFormulaParam
- Additional data for filterFormula (e.g. agreement's typedId,...)null
if no customer found)Object otherCustomer(String parameterName)
parameterName
- The name of the parameterObject otherCustomer(String parameterName, String attributeName)
parameterName
- The name of the parameterattributeName
- The attribute which value to return (null
for the entire object)Object otherCustomer(String parameterName, String attributeName, boolean defaultFromParent)
parameterName
- The name of the parameterattributeName
- The attribute whose value should be returned (null
for the entire object)defaultFromParent
- Determines whether to look up the attribute value from the parent customer (if any) in case it is null
in the customerObject customerExtension(String extensionName, Filter... filters)
extensionName
Example:
def filter = Filter.equal("attribute1", "ShipTo") // Type def addresses = api.customerExtension("Addresses", filter) if (addresses) { def address = addresses.getAt(0) ... }
extensionName
- The name of the extensionfilters
- None, one or more Filter
object that narrow down the CX search<T extends CalculableLineItem> T getCalculableLineItem(Object clic, String lineId)
T
- ContractLineItem (CTLI), QuoteLineItem (QLI) or RebateAgreementLineItem (RBALI)clic
- The CLIC to which the line item belongs, it may either be the CLIC object as such (its map representation to be exact) or typedId or a uniqueName.lineId
- The lineId of the line itemObject getCalculableLineItemResult(Object cli, String... resultNamesOrLabels)
Note: The line item object will typically be fetched via getCalculableLineItem(Object, String)
.
cli
- The calculable line itemresultNamesOrLabels
- The result names or labelsObject getCalculableLineItemCollection(String typedId)
typedId
- The typeId of the objectnull
if an invalid typedId was passedObject createNewRevision(String typedId)
typedId
- The typeId of the objectnull
if an invalid typedId was passedvoid addWarning(String message)
Example:
def cost = if (!cost) { api.addWarning("Missing cost") }
message
- The warning text messageObject contextByLabel(String label)
label
- The logic element labelObject vLookup(String parameterName)
parameterName
where the column 'name' matches the value
entered by the user and returns the value from the column 'value'.parameterName
- The name of the price parameter tablefindLookupTableValues(String, Filter...)
Object vLookup(String parameterName, Object attributeNameOrKeyOrRangeValue)
parameterName
where the column 'name' (for LTV or MLTV) or 'key1' (for MLTV2-6)
matches the attributeNameOrKeyOrRangeValue value
and returns the value from the column 'value' (LTV) or 'attribute1' (MLTV).
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.
Example:
def productGroup = api.product("attribute2") def shippingCost = api.vLookup("ShippingCosts", productGroup)
parameterName
- The name of the price parameter tableattributeNameOrKeyOrRangeValue
- A predefined key or range value or in case of a matrix lookup a user entryfindLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key)
parameterName
where the column 'key1' matches the key1
parameter
and returns the value of the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from cache.
Example:
def prevailing = api.vLookup("Manufacturer", "attribute1", "Meat company")
parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey
- The key of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key1, String key2)
parameterName
where the columns 'key1'-'key2' match the key1
-key2
parameters
and returns the value from the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.
Example:
def exchangeRate = api.vLookup("ExchangeRate", "attribute1", "EUR", "USD")
parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey1
- The key1 of the parameter tablekey2
- The key2 of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key1, String key2, String key3)
parameterName
where the columns 'key1'-'key3' match the key1
-key3
parameters
and returns the value from the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.
Example:
def exchangeRate = api.vLookup("ExchangeRate", "attribute1", "EUR", "USD", "2018")
parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey1
- The key1 of the parameter tablekey2
- The key2 of the parameter tablekey3
- The key3 of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key1, String key2, String key3, String key4)
parameterName
where the columns 'key1'-'key4' match the key1
-key4
parameters
and returns the value from the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey1
- The key1 of the parameter tablekey2
- The key2 of the parameter tablekey3
- The key3 of the parameter tablekey4
- The key4 of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key1, String key2, String key3, String key4, String key5)
parameterName
where the columns 'key1'-'key5' match the key1
-key5
parameters
and returns the value from the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey1
- The key1 of the parameter tablekey2
- The key2 of the parameter tablekey3
- The key3 of the parameter tablekey4
- The key4 of the parameter tablekey5
- The key5 of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object vLookup(String parameterName, String attributeName, String key1, String key2, String key3, String key4, String key5, String key6)
parameterName
where the columns 'key1'-'key6' match the key1
-key6
parameters
and returns the value from the column attributeName
.
Once the record is found, it remains cached during the whole calculation and
the next call for the same arguments reads the value from the cache.parameterName
- The name of the price parameter tableattributeName
- The name of the attribute to retrievekey1
- The key1 of the parameter tablekey2
- The key2 of the parameter tablekey3
- The key3 of the parameter tablekey4
- The key4 of the parameter tablekey5
- The key5 of the parameter tablekey6
- The key6 of the parameter tableattributeName
findLookupTableValues(String, Filter...)
Object userEntry(String entryName)
entryName
- The name of the user entry parameterinput(String)
,
stringUserEntry(String)
,
(String...)
,
decimalUserEntry(String)
,
dateUserEntry(String)
,
dateRangeUserEntry(String)
,
dateTimeUserEntry(String)
,
booleanUserEntry(String)
,
option(String, Object...)
,
options(String, Object...)
,
filterBuilderUserEntry(String, String)
,
datamartFilterBuilderUserEntry(String, String, Object...)
,
otherProduct(String)
,
otherCustomer(String)
,
productGroupEntry(String...)
,
customerGroupEntry(String...)
,
rebateAgreementUserEntry(String, String)
,
anyUser(String)
,
inputMatrix(String, String...)
Object decimalUserEntry(String entryName)
entryName
- The name of the user entry parameterintegerUserEntry(String)
Object integerUserEntry(String entryName)
entryName
- The name of the user entry parameterdecimalUserEntry(String)
Object stringUserEntry(String entryName)
entryName
- The name of the user entry parametertextUserEntry(String)
Object stringUserEntry(String entryName, String textMask)
entryName
- The name of the user entry parametertextMask
- Optional text mask that is displayed in the UItextUserEntry(String)
Object stringUserEntry(String entryName, String textMask, String label)
entryName
- The name of the user entry parametertextMask
- Optional text mask that is displayed in the UIlabel
- Label of the entry boxtextUserEntry(String, String)
Object textUserEntry(String entryName)
entryName
- The name of the user entry parameterstringUserEntry(String)
Object textUserEntry(String entryName, String label)
entryName
- The name of the user entry parameterlabel
- The label of the entry boxstringUserEntry(String, String, String)
Object booleanUserEntry(String entryName)
entryName
- The name of the user entry parameterObject dateUserEntry(String entryName)
entryName
- The name of the user entry parameterparseDate(String, String)
,
timeUserEntry(String)
,
dateTimeUserEntry(String)
,
dateRangeUserEntry(String)
Object dateRangeUserEntry(String entryName)
entryName
- The name of the user entry parameterparseDate(String, String)
,
timeUserEntry(String)
,
dateTimeUserEntry(String)
,
dateUserEntry(String)
Object timeUserEntry(String entryName)
entryName
- The name of the user entry parameterparseDate(String, String)
,
dateUserEntry(String)
,
dateTimeUserEntry(String)
,
dateRangeUserEntry(String)
Object dateTimeUserEntry(String entryName)
Rendered as a datetime picker field.
Important: The format implicitly uses the GMT/UTC time zone and so the returned value may differ from what was entered in on the client (as the client time may be in a different time zone).
entryName
- The name of the user entry parameterparseDate(String, String)
Object productGroupEntry(String... entryName)
entryName
- The name of the user entry parameter[ "productFieldName" : "attribute3", "productFieldLabel" : "Business Unit", "productFieldValue" : "MeatBall" ]
Object productGroupEntry(String entryName, String filterFormulaName, Object filterFormulaParam)
entryName
- The name of the user entry parameterfilterFormulaName
- A unique name of a formula that will be triggered when the customer picker opensfilterFormulaParam
- Additional data for filterFormula[ "productFieldName" : "attribute3", "productFieldLabel" : "Business Unit", "productFieldValue" : "MeatBall" ]
Object customerGroupEntry(String... entryName)
entryName
- The name of the user entry parameter[ "customerFieldName" : "attribute3", "customerFieldLabel" : "Customer Type", "customerFieldValue" : "Restaurant" ]
productGroupEntry(String...)
Object customerGroupEntry(String entryName, String filterFormulaName, Object filterFormulaParam)
entryName
- The name of the user entry parameterfilterFormulaName
- A unique name of a formula that will be triggered when the customer picker opensfilterFormulaParam
- Additional data for filterFormula (e.g. agreement's typedId,...)[ "customerFieldName" : "attribute3", "customerFieldLabel" : "Customer Type", "customerFieldValue" : "Restaurant" ]
productGroupEntry(String...)
Object multiTierEntry(String entryName, String... arguments)
entryName
- The name of the user entry parameterarguments
- Two value hints: sort type (can be either "ASC" which is the default or "DESC") and order validation type
(can be "VALIDATE" or "NO_VALIDATION").Object option(String entryName, Object... options)
Example 1:
return api.option("Currency", ["EUR", "USD"])
Example 2:
def salesOrgs = api.findLookupTableValues("SalesOrg").collect{ it.name } return api.option("SalesOrg", salesOrgs)
entryName
- The name of the user entry parameteroptions
- An arbitrary number of options that should be displayed in the drop down listoptions(String, Object...)
Object option(String entryName, List<Object> options, Map<String,Object> labels)
Example:
def salesOrgMap = api.findLookupTableValues("SalesOrg").collectEntries{ [(it.name) : it.name] } return api.option("SalesOrg", salesOrgMap.keySet() as List, salesOrgMap)
entryName
- The name of the user entry parameteroptions
- An arbitrary number of options that should be displayed in the drop down listlabels
- A map [value : label] of labels that should be shown in the UI. If null or empty will behave same as api.option() without a label definition.options(String, List, Map)
Object options(String entryName, Object... options)
entryName
- The name of the user entry parameteroptions
- An arbitrary number of options that should be displayed in the drop down listoption(String, Object...)
Object options(String entryName, List<Object> options, Map<String,Object> labels)
entryName
- The name of the user entry parameteroptions
- An arbitrary number of options that should be displayed in the drop down listlabels
- A map [value : label] of labels that should be shown in the UI. If null or empty will behave same as option(String, Object...)
without a label definition.Object filterBuilderUserEntry(String entryName, String typeCode)
typeCode
parameter.
It is rendered as a filter builder widget allowing to construct a filter (e.g. to define filter for Products, set the typeCode
to P
).
The filter object can be used in other functions, like find(String, Filter...)
, stream(String, String, Filter...)
count(String, Filter...)
etc.
entryName
- The name of the user entry parametertypeCode
- A type code string of the type of the object for which the filter is set. The supported type codes currently are "P" (Product data) and "C" (Customer data).Object datamartFilterBuilderUserEntry(String entryName, String source, Object... args)
The filter can be used in DatamartContext.Query.where(Filter...)
of the datamartQuery(Object...)
.
It will render a FilterBuilder widget entry allowing to construct a filter object filtering on the specified Data Source.
Example:
def filter1 = datamartFilterBuilderUserEntry("ProductGroup", "Transactions_DM") def dimFilterList = ["CustomerId", "ProductId"] def filter2 = datamartFilterBuilderUserEntry("ProductGroup", "Transactions_DM", dimFilterList) def dimFilterMap = ["CustomerId" : "CD-00155", "ProductId" : "MB-0005"] def filter3 = datamartFilterBuilderUserEntry("ProductGroup", "Transactions_DM", dimFilterMap, Filter.equal("Country", "DE"))
entryName
- The name of the user entry parametersource
- The name of the source for which the filter is set. The resolution of the source is as follows:
args
- There can be up to 2 arguments: one can be a Map or List and the other a Filter. The order does not matter.
If the argument is a Map, each pair [fieldName : value] will be used as a filter.Object pricelist(String listName)
listName
- The name of the price listresultPrice
of the price list record for the SKUObject pricelist(String listName, String attributeName)
attributeName
(considering a manual override) of an SKU being calculated in a price list of the given name.
The price list line has to be approved and the targetDate of the price list has to be prior to the calculation targetDate.
If multiple price lists are found, the one with the targetDate closer to the calculation targetDate is chosen.listName
- The name of the price listattributeName
- The name of the attribute to retrieveattributeName
column of the price list recordpricelistItem(String, String)
Object pricelist(String listName, String attributeName, String sku)
listName
- The name of the price listattributeName
- The name of the attribute to retrievesku
- The SKU to useattributeName
column of the price list recordpricelistItem(String, String)
Object pricelist(String listName, String attributeName, String sku, String key2)
attributeName
(considering a manual override) of the given SKU in a matrix price list of the given name.
The price list line has to be approved and the targetDate of the price list has to be prior to the calculation targetDate.
If there are multiple price lists of the same name, the one with the targetDate closer to the calculation targetDate is chosen.listName
- The name of the price listattributeName
- The name of the attribute to retrievesku
- The SKU to usekey2
- The key2 to useattributeName
column of the matrix price list recordpricelistItem(String, String, String)
Object pricelistItem(String listName)
listName
- The name of the price listpricelist(String)
Object pricelistItem(String listName, String sku)
listName
- The name of the price listsku
- The SKU to usepricelist(String, String, String)
Object pricelistItem(String listName, String sku, String key2)
listName
- The name of the price listsku
- The SKU to usekey2
- The key2 to usepricelist(String, String, String, String)
Map<String,Object> getPricelistItem(String listName)
pricelistItem(String)
function. However, it optimizes the subsequent processing by providing the results as a map directly.listName
- The name of the price list. Target date and SKU matching applies.pricelistItem(String)
Object bom()
Object bom(String lookupTableName)
lookupTableName
- The parameter table nameObject bom(String lookupTableName, String categoryName)
lookupTableName
- The parameter table namecategoryName
- The category name to filter onObject bom(String lookupTableName, String categoryName, String materialName)
lookupTableName
- The parameter table namecategoryName
- The category name to filter onmaterialName
- The material to filter onObject bomList()
Object anyUser(String entryName)
entryName
- The name of the entry parameternull
Object user(String attributeName)
Example:
// retrieves the email of the user def email = api.user("email")
attributeName
- The attribute to returnObject user()
Example:
// retrieves the email of the user def email = api.user()?.email
Object input(String inputName)
inputName
- The parameter nameuserEntry(String)
Object inputMatrix(String inputMatrixName, String... columnNames)
inputMatrixName
- The name of the parametercolumnNames
- The column names/labelsObject inputMatrix(String inputMatrixName, Map<String,Object> paramConfig, String... columns)
inputMatrixName
- The name of the parameterparamConfig
- Map of configuration settings with the following options (key, value):
columns
- The column names/labelsObject parsableInputFile(String inputName)
inputName
- The name of the parameterObject parsableInputFileData(String inputName)
inputName
- The name of the parameterObject parsableInputFileDataFromHandle(String fileHandle)
fileHandle
- The value of the parameterObject filter(String property, Object value)
Filter.equal(String, Object)
insteadExample:
def cas = api.find("CA", api.filter("assignmentId", mplId), api.filter("assignmentType", "MPL") )
property
- The name of the property to filter onvalue
- The specified valueFilter filterFromMap(Map<String,Object> filterMap)
filterMap
- The filter in the form of nested mapsObject filter(String property, Object opString, Object value)
Filter
functions instead
Note: This method is sort of dynamic. Dynamic in a sense that if the opString
does not actually represent a valid operator (e.g. "="),
the passed value will then be treated as the lower bound and the value
as the upper bound. In other words, the resulting filter will look like this:
Filter.and(Filter.greaterOrEqual(property, opString), Filter.lessThan(property, value))
. If either parameter is null
, its part
is skipped.
Example:
datamartQuery.where(api.filter("PricingDate", ">", targetDate.minus(365).format("yyyy-MM-dd")))
property
- The name of the property to filter onopString
- One out of : "=", "<", "<=", ">", ">=", "<>", "~". If different, it gets treated as the lower bound value. Please see the remark.value
- The specified value (or an upper bound)Filter.equal(String, Object)
,
Filter.lessThan(String, Object)
,
Filter.lessOrEqual(String, Object)
,
Filter.greaterOrEqual(String, Object)
,
Filter.greaterThan(String, Object)
,
Filter.notEqual(String, Object)
,
Filter.like(String, String)
,
Filter.and(Filter...)
,
Filter.or(Filter...)
,
Filter.in(String, Object...)
,
Filter.notIn(String, Object...)
Filter customerToRelatedObjectsFilter(String relatedObjectTypeCode, String customerId)
Example:
def filter = api.customerToRelatedObjectsFilter("RBA", "104083") // customerId=104083 def rbas = api.find("RBA", 0, 0, null, filter) api.trace("rbas for customer #104083", null, rbas)
relatedObjectTypeCode
- TypeCode of the related object type. The possible values are:
customerId
- Customer.id to filter onFilter relatedObjectToCustomersFilter(String relatedObjectTypedId)
Example:
def ras = api.find("RBA", 0, 1, null, null) ras.each { def filter = api.relatedObjectToCustomersFilter(it.typedId) def customers = api.find("C", 0, 0, null, filter) ... }
relatedObjectTypedId
- TypedId of the related object. Its type needs to be one of:
Filter productToRelatedObjectsFilter(String relatedObjectTypeCode, String sku)
Example:
def ras = api.find("RBA", 0, 1, null, null) ras.each { def raId = it.typedId.tokenize(".")[0] as Long def raFilter = api.relatedObjectToCustomersFilter("RBA", raId) def customers = api.find("C", 0, 0, null, filter) ... }
relatedObjectTypeCode
- TypeCode of the related object type. The possible values are:
sku
- Product.id to filter onFilter relatedObjectToProductsFilter(String relatedObjectTypedId)
relatedObjectTypedId
- TypedId of the related object. Its type needs to be one of:
boolean isUserInGroup(String userGroupName, String loginUserName)
Example:
def user = api.user("loginName") if (api.isUserInGroup("Manager", user)) { ... }
userGroupName
- The group nameloginUserName
- The login name of the uservoid trace(String functionName, String parameters, Object result)
functionName
- A function name (free text of your choice)parameters
- Parameters to traceresult
- The result of the tracevoid trace(String functionName, Object result)
functionName
- A function name (free text of your choice)result
- The result of the tracevoid trace(Object result)
result
- The value to tracevoid log(String msg, Object arg1)
logInfo(String, Object)
or logWarn(String, Object)
.
Logs a DEBUG message to the system error log which can be displayed in menu Tools / Logs / View Log.
Log message can contain placeholders like {} which are then filled in dynamically with the argument's value.
Note: To enable this function, you need to tick the setting "Allow Groovy logging to system log" in menu Tools / Configuration / General Settings.msg
- The log message to printarg1
- The arguments for the log message.logInfo(String, Object)
,
logWarn(String, Object)
void log(Object msg)
logInfo(Object)
or logWarn(Object)
.
Logs a DEBUG message to the system error log which can be displayed in menu Tools / Logs / View Log.
Log message can contain placeholders like {} which are then filled in dynamically with the argument's value.
Note: To enable this, you need to tick the setting "Allow Groovy logging to system log" in menu Tools / Configuration / General Settings.msg
- The message accompanying the exceptionlogInfo(Object)
,
logWarn(Object)
void logInfo(String msg, Object arg1)
Example:
def sku = api.product("sku") api.markItemDirty() api.logInfo("SKU marked as dirty", sku)
msg
- The log message to printarg1
- The arguments for the log messagelog(String, Object)
,
logWarn(String, Object)
void logInfo(Object msg)
Example:
api.logInfo("No items to be calculated")
msg
- The log message to printlog(Object)
,
logWarn(Object)
void logWarn(String msg, Object arg1)
Example:
def sku = api.product("sku") if (checkItem()) { api.logWarn("Incorrect or missing 'sku' parameter", sku) }
msg
- The log message to printarg1
- The arguments for the log messagelog(String, Object)
,
logInfo(String, Object)
void logWarn(Object msg)
Example:
api.logWarn("SKU cannot be null")
msg
- The message accompanying the exceptionlog(Object)
,
logInfo(Object)
ContextParameter getParameter(String parameterName)
ContextParameter
object.
This can then be further modified as required.
Example:
def p = api.getParameter("Quantity") // retrieve the context parameter with the same name as the input if (p != null && p.getValue() == null) { p.setLabel("Required Quantity") // set the displayed label p.setRequired(true) // set the mandatory hint p.setReadOnly(false) // set the read only flag p.setValue(1) // set the default value with which the input is pre-populated } return qty ?: 1 // if user doesn't specify a value, return 1
parameterName
- The named parameter to retrievenull
Map<String,Object> currentContext(String sku)
Note: If used within a context that has a secondary key, only the first object is returned.
sku
- The SKU to look forMap<String,Object> currentContext(String sku, String key2)
sku
- The SKU to look forkey2
- The key2 to look forMap<String,Object> previousContext(String sku)
Note: If used within a context that has a secondary key, only the first object is returned.
sku
- The SKU to look forMap<String,Object> previousContext(String sku, String key2)
sku
- The SKU to look forkey2
- The key2 to look forString contextName()
String contextType()
String contextTypedId()
Object getProperty(Object object, String path)
object
- The object whose value to retrievepath
- The attribute nameObject getPropertyByElementName(Object object, String elementName)
object
- The object whose value to retrieveelementName
- The elementName valuenull
if invalid object or no matching meta foundObject currentItem()
Example:
def currentItem = api.currentItem() def currentSku = currentItem != null ? currentItem.attribute20 : api.product("attribute20")
Object currentItemByElementName(String elementName)
elementName
- The element nameObject currentItem(String attributeName)
currentItem()
but returns only the specified attribute.
Example:
def activePrice = api.currentItem("activePrice")
attributeName
- The attribute to retrieveSet<Object> contextSkuSet(int startRow)
The form of the SKU context differs, e.g., in case of the product detail formula executed via price grid details, the resulting set will contain all SKUs of the left-pane grid.
Note #1: If the SKU context is not supported by the current formula
execution, null
is returned.
Note #2: A maximum of 200 SKUs is returned per one call. If there are more,
startRow
must be used to get all SKUs in the set.
startRow
- The starting row of the result setnull
if the SKU context is not
available for the current formula executionint getMaxFindResultsLimit()
find(String, int, int, String, Filter...)
and its variations can return in one call.
The value is set in formulaEngine.script.findMaxResults
system parameter.
The default value is 2000 records.find(String, int, int, String, Filter...)
List<Object> find(String typeCode, Filter... filters)
find(String, int, int, String, List, Filter...)
in order to always specify the fields to be returned because of performance.find(String, int, int, String, List, Filter...)
instead because of performance reasons.typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
filters
- An optional list of filters (that will evaluated using AND operator)stream(String, String, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, Filter... filters)
find(String, int, int, String, List, Filter...)
because of performance you should always specify the fields to be returned.find(String, int, int, String, List, Filter...)
instead because of performance reasons.typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
filters
- An optional list of filters (that will evaluated using AND operator)startRow
- The starting row of the result setstream(String, String, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, String sortBy, Filter... filters)
find(String, int, int, String, List, Filter...)
because of performance you should always specify the fields to be returned.find(String, int, int, String, List, Filter...)
instead because of performance reasons.
Example:
def sku = api.product("sku") def filters = [ Filter.equal("name", "Competition"), Filter.equal("sku", sku), ] // sort by competitor's price ASC def competitors = api.find("PX", 0, "attribute1", *filters) competitors.each { ... }
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
startRow
- The starting row of the result setsortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfilters
- An optional list of filters (that will evaluated using AND operator)stream(String, String, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, int maxRows, String sortBy, Filter... filters)
Example:
def sku = api.product("sku") def filters = [ Filter.equal("name", "Competition"), Filter.equal("sku", sku), ] // sort by competitor's price ASC def competitors = api.find("PX", 0, api.getMaxFindResultsLimit(), "-attribute2", *filters) competitors.each { ... }
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
startRow
- The starting row of the result setmaxRows
- The maximum number of rows to retrieve. Value can be up to getMaxFindResultsLimit()
. If set to 0 it will default to 200sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfilters
- An optional list of filters (that will evaluated using AND operator)getMaxFindResultsLimit()
,
stream(String, String, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, int maxRows, String sortBy, List<String> fields, Filter... filters)
Example:
def sku = api.product("sku") def filters = [ Filter.equal("name", "Competition"), Filter.equal("sku", sku), ] // sort by competitor's price ASC def competitors = api.find("PX", 0, api.getMaxFindResultsLimit(), "-attribute2", ["attribute2", "attribute5", "attribute6"], *filters) competitors.each { ... }
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
startRow
- The starting row of the result setmaxRows
- The maximum number of rows to retrieve. Value can be up to getMaxFindResultsLimit()
. If set to 0 it will default to 200sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- A list of fields to returned in the result. If you really need all fields, you can set this parametr to nullfilters
- An optional list of filters (that will evaluated using AND operator)getMaxFindResultsLimit()
,
stream(String, String, List, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, int maxRows, String sortBy, List<String> fields, boolean distinctValuesOnly, Filter... filters)
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
startRow
- The starting row of the result setmaxRows
- The maximum number of rows to retrieve. Value can be up to getMaxFindResultsLimit()
. If set to 0 it will default to 200sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- A list of fields to returned in the result. If you really need all fields, you can set this parametr to nulldistinctValuesOnly
- Fetches distinct/all values. The use case here is fetching distinct single column values.filters
- An optional list of filters (that will evaluated using AND operator)getMaxFindResultsLimit()
,
stream(String, String, List, boolean, Filter...)
,
count(String, Filter...)
List<Object> find(String typeCode, int startRow, int maxRows, String sortBy, Map<String,String> fields, boolean distinctValuesOnly, Filter... filters)
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
startRow
- The starting row of the result setmaxRows
- The maximum number of rows to retrieve. Value can be up to getMaxFindResultsLimit()
. If set to 0 it will default to 200sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- A map of pairs [fieldname : aggregation] holding fields to be returned in the result where aggregation can be one of SUM, AVG, MIN or MAX
The key of the map is the field name. The value can be a field operator like SUM, AVG, MIN or MAX.distinctValuesOnly
- Fetches distinct/all values. The use case here is fetching distinct single column values.filters
- An optional list of filters (that will evaluated using AND operator)getMaxFindResultsLimit()
,
stream(String, String, Map, boolean, Filter...)
,
count(String, Filter...)
AbstractProducer.ResultIterator stream(String typeCode, String sortBy, Filter... filters)
stream(String, String, List, Filter...)
instead because of performance reasons.
Important note: you have to close the iterator after iterating the data using Closeable.close()
.
Example:
def filters = [ Filter.equal("attribute2", "Active") ] def products = api.stream("P", "-attribute1", *filters) products.each { product -> ... }
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfilters
- An optional list of filters (that will evaluated using AND operator)find(String, int, String, Filter...)
,
count(String, Filter...)
AbstractProducer.ResultIterator stream(String typeCode, String sortBy, List<String> fields, Filter... filters)
Important note: you have to close the iterator after iterating the data using Closeable.close()
.
Example:
def filters = [ Filter.equal("attribute2", "Active") ] def products = api.stream("P", "-attribute1", ["attribute2"], *filters) products.each { product -> ... }
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- A list of attributes you want to return in the result, i.e. skip all attributes not contained in the list that the search would return otherwise.filters
- An optional list of filters (that will evaluated using AND operator)find(String, int, int, String, List, Filter...)
,
count(String, Filter...)
AbstractProducer.ResultIterator stream(String typeCode, String sortBy, List<String> fields, boolean distinctValuesOnly, Filter... filters)
Important note: you have to close the iterator after iterating the data using Closeable.close()
.
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- A list of attributes you want to return in the result, i.e. skip all attributes not contained in the list that the search would return otherwise.distinctValuesOnly
- Fetches distinct/all values. The use case here is fetching distinct single column values.filters
- An optional list of filters (that will evaluated using AND operator)find(String, int, int, String, List, boolean, Filter...)
,
count(String, Filter...)
AbstractProducer.ResultIterator stream(String typeCode, String sortBy, Map<String,String> fields, boolean distinctValuesOnly, Filter... filters)
Important note: you have to close the iterator after iterating the data using Closeable.close()
.
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
sortBy
- String of fields/attributes, separated by comma, based on which the resultset should be sorted. Any field can be prefixed with '-' for descending sort orderfields
- Map of pairs [fieldname : aggregation] holding fields to be returned in the result where aggregation can be one of SUM, AVG, MIN or MAX
The key of the map is the field name. The value can be a field operator like SUM, AVG, MIN or MAXdistinctValuesOnly
- Fetches distinct/all values. The use case here is fetching distinct single column values.filters
- An optional list of filters (that will evaluated using AND operator)find(String, int, int, String, Map, boolean, Filter...)
,
count(String, Filter...)
boolean emit(Object obj) throws InterruptedException
obj
- The object to be emitted/inserted in the emit queueInterruptedException
- if interrupted while waitingvoid emitRebateRecords(String dateFieldName, String sortBy, Filter... filters) throws InterruptedException
dateFieldName
- The name of the field to be substituted in the RebateRecord calculationBase (a DMDataSlice object that includes a generic time dimension filter)sortBy
- The RebateRecord field on which to sortfilters
- The filters to apply to the RebateRecord searchInterruptedException
- if interrupted while waitingboolean emitPersistedObject(String typedId) throws InterruptedException
emitRebateRecords(java.lang.String, java.lang.String, com.googlecode.genericdao.search.Filter...)
.typedId
- The typedId of the PersistedObject to emitInterruptedException
- if interrupted while waitingboolean emitPersistedObject(String typeCode, Long id) throws InterruptedException
emitRebateRecords(java.lang.String, java.lang.String, com.googlecode.genericdao.search.Filter...)
.typeCode
- The typeCode of the PersistedObject to emitid
- The ID of the PersistedObject to emitInterruptedException
- if interrupted while waitingint count(String typeCode, Filter... filters)
find(String, int, int, String, List, Filter...)
would return.typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
filters
- A list of Filter
objects that are ANDed togetherLookupTable findLookupTable(String tableName)
tableName
- The name of the price parameter tablenull
if the table does not exists or it's validAfter > targetDateList<Object> findLookupTableValues(String tableName, Filter... filters)
Example:
api.retainGlobal = true // for the first time if (api.global.salesOrgs == null) { // store all values as a Map [name : value] to global cache api.global.salesOrgs = api.findLookupTableValues("SalesOrg").collectEntries { [(it.name): it.value] } } return api.global.salesOrgs
tableName
- The name of the price parameter tablefilters
- Optional extra Filter
null
WorkflowInfo findWorkflowInfo(String approvableTypeCode, Object approvableId)
Example:
def quoteUniqueName = "P-123" def quote = api.find('Q', 0, 1, Filter.equal("uniqueName", quoteUniqueName)).getAt(0) return quote ? api.findWorkflowInfo('Q', quote.id) : null
approvableTypeCode
- The type code of approvable. Approvables are e.g. quotes, rebate agreements, data change requests etc.approvableId
- ID of the approvablenull
if not foundfindPreviousWorkflowInfo(String, String...)
,
findPreviousApprovableState(String, String...)
Map<String,Object> findPreviousApprovableState(String typedId, String... workflowStatuses)
typedId
- Approvable entity typed IDworkflowStatuses
- Only DENIED or WITHDRAWN are supportedfindWorkflowInfo(String, Object)
WorkflowInfo findPreviousWorkflowInfo(String typedId, String... workflowStatuses)
typedId
- Approvable entity typed IDworkflowStatuses
- Only DENIED or WITHDRAWN are supportedfindWorkflowInfo(String, Object)
List<CustomerAssignment> findCustomerAssignments(String customerId)
customerId
- The customer whose assignments are searched forList<Pricelist> findPricelists(Date targetDate, String listName)
targetDate
- The targetDate to uselistName
- Price list name. If null
, the list name is not included in search.List<Simulation> findSimulations(Date targetDate, String simulationName)
targetDate
- The targetDate to usesimulationName
- Simulation name. If null
, the simulation name is not included in search.List<PriceGrid> findPriceGrids(Date targetDate, String priceGridName)
targetDate
- The targetDate to usepriceGridName
- Price grid name. If null
, the price grid name is not included in search.List<CalculatedFieldSet> findCalculatedFieldSets(Date targetDate, String cfsName)
targetDate
- Target date for the CFScfsName
- CFS name. If null
, the CFS name is not included in search.List<ManualPricelist> findManualPricelists(Date targetDate, String listName)
targetDate
- The targetDate to uselistName
- Price list name. If null
, the list name is not included in search.List<SummaryCalculableObjectItem> findApprovedPricelistItems(String sku)
sku
- The SKU to filter onList<Customer> findCustomersInGroup(CustomerGroup group)
group
- The group to matchList<Customer> findCustomersInGroup(CustomerGroup group, int startRow, String sortBy)
group
- The customer groupstartRow
- The starting row number (maximum 200 rows returned at once)sortBy
- A sort key. null
if no sorting is required.Object getManualOverride(String elementName)
Note that the manualOverride works as a flag - when it is set for an element, the final value of that element is taken from the manually entered value and the calculation of that element does not run at all. If this flag is not set, the final value is the calculated result.
elementName
- The formula/result element that is overriddennull
if not overriddenvoid removeManualOverride(String elementName)
If you have a condition to remove the manual override, it is recommended to put this condition in a separate logic element which is always executed (not in the same one which has the manual override allowed; the reason is that once the user enters a value manually, the element calculation does run at all, so the condition would not be evaluated).
elementName
- The formula/result element that is overriddenvoid abortCalculation()
isSyntaxCheck()
after the parameters are gathered.
Example:
if (api.isSyntaxCheck()) { api.abortCalculation() }
void throwException(String errorMessage) throws XExpression
errorMessage
- The error message that is displayedXExpression
- The custom calculation exceptionvoid markItemDirty(String sku)
getIterationNumber()
, markItemClean()
.
The maximum number of dirty passes is defined by the server configuration constant maxDirtyCalculations
defined for the whole instance. The default is 1 dirty pass.sku
- The item to have the dirty flag setmarkItemClean(String)
void markItemDirty(String sku, String key2)
maxDirtyCalculations
defined for the whole instance. The default is 1 dirty pass.
See also getIterationNumber()
, markItemClean()
.sku
- The item to have the dirty flag setkey2
- key2 fieldmarkItemClean(String, String)
void markItemDirty()
maxDirtyCalculations
defined for the whole instance. The default is 1 dirty pass.
See also getIterationNumber()
, markItemClean()
.markItemClean()
void markItemClean()
markItemDirty()
.markItemDirty()
void markItemClean(String sku, String key2)
markItemDirty(String, String)
.sku
- The item from which to remove the dirty flagkey2
- key2 fieldmarkItemDirty(String, String)
void markItemClean(String sku)
markItemDirty(String)
.sku
- The item from which to remove the dirty flagmarkItemDirty(String)
boolean isSecondPass()
getIterationNumber()
> 0 instead.int getIterationNumber()
markItemDirty()
was called in the previous pass
2 means: 2nd dirty pass, markItemDirty()
was called in the previous pass
and so on
The maximum number of dirty passes is defined by the server configuration constant maxDirtyCalculations
defined for the whole instance. The default is 1 dirty pass.String formatString(String locale, String format, Object... args)
String.format(java.lang.String, java.lang.Object...)
.locale
- The locale (as a String)format
- The format stringargs
- The arguments to pass onString formatNumber(String pattern, Object n)
NumberFormat
and DecimalFormat.applyPattern(java.lang.String)
apply.pattern
- The pattern stringn
- The number to formatString formatNumber(String locale, String pattern, Object n)
NumberFormat
and DecimalFormat.applyPattern(java.lang.String)
apply.pattern
- The pattern stringn
- The number to formatlocale
- The locale to use for formattingObject jsonDecode(String json)
json
- The input JSON stringObject jsonDecodeList(String json)
json
- The input JSON stringObject jsonEncode(Object input)
input
- The input object, usually a mapObject jsonEncode(Object input, boolean omitNull)
input
- The input object, usually a mapomitNull
- Determines is null values should be omittedvoid criticalAlert(String msg)
msg
- The alert messageredAlert(String)
,
yellowAlert(String)
void redAlert(String msg)
msg
- The alert messagecriticalAlert(String)
,
yellowAlert(String)
void yellowAlert(String msg)
msg
- The alert messagecriticalAlert(String)
,
redAlert(String)
void setAlertMessage(String msg)
msg
- The alert messageResultFlexChart buildFlexChart(Object definition)
buildFlexChart(null, definition)
See the full documentation in buildFlexChart(Object)
.definition
- the definition of the FlexChart
buildHighchart(Map)
,
buildFlexChart(String, Object)
ResultFlexChart buildFlexChart(String baseTemplateToUse, Object definition)
FlexChart
from the passed definition
by
merging it with options
defined within the
baseTemplateToUse
template.
Although it may change in future releases, for now, a
FlexChart
is nothing else than a Highcharts
chart. Therefore, the passed definition
(also applies to the
baseTemplateToUse
template) must denote
Highcharts options
- please consult Highcharts
documentation for more details.
Since Highcharts options
are normally specified by a
JavaScript object literal
, the passed
definition
must be either a JSON
string
representing such object literal
, or any object
which can be mapped to such JSON
representation. Therefore,
typically the definiton
will be passed as a
map of maps
.
Example:
Note that not alldef definition = [ chart: [ type: "bar" ], title: [ text: "A common FlexChart" ], series: [ [ data: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] ] ] ] api.buildFlexChart(definition)
Highcharts options
are supported.
Moreover, usage of some options is prohibited deliberately. These are
currently global
, events
and every
JavaScript function
-based options.
Note: FlexChart
templates are defined by an administrator in
the 'Configuration
' section.
baseTemplateToUse
- The name of the template to use as a basis for merging with
the passed definition
; if null
, the
predefined Default template is useddefinition
- The definition of the FlexChart
; currently, this
will typically be a string or map of maps containing
Highcharts options
FlexChart
,
baseTemplateToUse
and type of the result - which
will always be 'FLEXCHART', herebuildFlexChart(Object)
,
buildHighchart(Map)
ResultHighchart buildHighchart(Map<String,?> definition)
ResultHighchart
from the passed definition
.
FlexChart
, the definition is passed straight to the
Highcharts
library, currently release 6.1. There is no validation,
no templates merging, and JavaScript functions are not supported.definition
- The definition of the Highchart
as a map of maps and arraysbuildFlexChart(Object)
ResultHighmap buildHighmap(Map<String,?> definition)
ResultHighmap
from the passed definition
.
FlexChart
, the definition is passed straight to the
Highmaps
library, currently release 6.1. There is no validation,
no templates merging, and JavaScript functions are not supported.
HighChart
provide better performance than FlexChart
sincedefinition
- The definition of the Highmap
as a map of maps and arraysAdaptiveHistogram newAdaptiveHistogram()
ItemSummaryQuery<Pricelist> getPricelistSummaryQuery()
runSummaryQuery(ItemSummaryQuery)
.
This query runs against price list(s).ItemSummaryQuery<Simulation> getSimulationSummaryQuery()
runSummaryQuery(ItemSummaryQuery)
.
This query runs against simulation(s).ItemSummaryQuery<PriceGrid> getPriceGridSummaryQuery()
runSummaryQuery(ItemSummaryQuery)
.
This query runs against price grid(s).ItemSummaryQuery<RebateRecordSet> getRebateRecordSummaryQuery()
runSummaryQuery(ItemSummaryQuery)
.
This query runs against rebate records.List<Map<String,Object>> runSummaryQuery(ItemSummaryQuery<? extends CalculableObject> query)
query
- The query to executeConfiguratorEntry createConfiguratorEntry(InputType type, String name)
type
- Input type of the parameter. Valid enum values are:
PRODUCT, PRODUCTGROUP, CUSTOMER, CUSTOMERGROUP, USERENTRY, STRINGUSERENTRY, OPTION,
INTEGERUSERENTRY, BOOLEANUSERENTRY, DATEUSERENTRY, TIMEUSERENTRY, DATETIMEUSERENTRY, MULTITIERENTRY,
INPUTMATRIX, OPTIONS, MATRIXLOOKUP, LOOKUP, FILTERBUILDER, DMFILTERBUILDER, DMFIELD, DMDIMFILTER,
CONFIGURATOR, HIDDENname
- The name of the parameterConfiguratorEntry createConfiguratorEntry(InputType type, String name, Date targetDate)
type
- Input type of the parameter. Valid enum values are:
PRODUCT, PRODUCTGROUP, CUSTOMER, CUSTOMERGROUP, USERENTRY, STRINGUSERENTRY, OPTION,
INTEGERUSERENTRY, BOOLEANUSERENTRY, DATEUSERENTRY, TIMEUSERENTRY, DATETIMEUSERENTRY, MULTITIERENTRY,
INPUTMATRIX, OPTIONS, MATRIXLOOKUP, LOOKUP, FILTERBUILDER, DMFILTERBUILDER, DMFIELD, DMDIMFILTER,
CONFIGURATOR, HIDDENname
- The name of the parametertargetDate
- Target date for the input parameter (not applicable to all input types)ConfiguratorEntry createConfiguratorEntry()
ConfiguratorEntryArray createConfiguratorEntryArray(Object... entries)
entries
- 0..N configurator entries. Supports also list nesting.ConfiguratorEntryArray#addEntry(ConfiguratorEntry)
,
ConfiguratorEntryArray#setEntries(List)
or
ConfiguratorEntryArray#getEntries()
Object configurator(String configuratorName, String formulaName)
configuratorName
- The name of the configurator, similar to other options' namesformulaName
- The name of the configurator formula which is used to drive the input selectionsObject configurator(String configuratorName, String formulaName, Object resultName)
configuratorName
- The name of the configurator, similar to other options' namesformulaName
- The name of the configurator formula which is used to drive the input selectionsresultName
- The result that should be returned (instead of the full configurator results map)Object configurator(String configuratorName, String formulaName, Object width, Object height)
configuratorName
- The name of the configurator, similar to other options' namesformulaName
- The name of the configurator formula which is used to drive the input selectionswidth
- The width of the configurator window. Can be a number (in pixels) or a percentage string.height
- The height of the configurator window. Can be a number (in pixels) or a percentage string.Object inlineConfigurator(String configuratorName, String formulaName)
configuratorName
- The name of the configurator, similar to other options' namesformulaName
- The name of the configurator formula which is used to drive the input selectionsDate parseDate(String pattern, String date)
Hint: For parsing datetimes (i.e. dates also including information about the time of the day), use the parseDateTime(String, String)
method instead.
Example:
def date = api.parseDate("yyyy-MM-dd", "2019-01-23")
pattern
- The pattern for parsing (see DateTimeFormat for pattern format specification)date
- The date as a String in the format specified by the pattern
parseDateTime(String, String)
,
parseDateTime(String, String, int, int)
DateTime parseDateTime(String pattern, String datetime)
Important note: This method will use the UTC time zone for parsing (unless the provided pattern
uses a syntax explicitly
specifying a time zone). If a different time zone is required, use the parseDateTime(String, String, int, int)
method which allows to
set a time zone by providing an offset to UTC in hours and minutes.
Example:
def now = api.parseDateTime("yyyy-MM-dd'T'HH:mm:ss", "2019-01-23T13:44:52") now.getYear() // 2019 now.getMonthOfYear() // 1 now.getDayOfMonth() // 23 now.getHourOfDay() // 13 now.getMinuteOfHour() // 44 now.getSecondOfMinute() // 52
pattern
- The pattern for parsing (see DateTimeFormat for pattern format specification)datetime
- The datetime as a String in the format specified by the pattern
parseDate(String, String)
,
parseDateTime(String, String, int, int)
DateTime parseDateTime(String pattern, String datetime, int tzHoursOffset, int tzMinutesOffset)
Important note: This method will always use the provided time zone, regardless of the possible time zone set explicitly in datetime
.
pattern
- The pattern for parsing (see DateTimeFormat for pattern format specification)datetime
- The datetime as a String in the format specified by the pattern
tzHoursOffset
- The offset in hours from UTC, from -23 to +23tzMinutesOffset
- The offset in minutes from UTC, from -59 to +59parseDateTime(String, String)
,
parseDate(String, String)
Filter createElementNameFilter(String elementName, Object fieldValue, String... listTypedIds)
elementName
- The element name (originates from the logic element name or MPL integration tag)fieldValue
- The value (= operator applied) of that attributelistTypedIds
- A list of typedId of the "header" objects. E.g. 34.PL. Supported type codes are PL, MPL, PG and SIMMap<String,Object> getItemCompleteCalculationResults(String typedId)
Note: These are not returned when using other methods (e.g., pricelistItem(String, String)
).
typedId
- The typedId of the item, e.g. 34.PLI. Supported type codes are PLI, XPLI, SIMI, XSIMI, PGI, XPGI and RRMap<String,Object> getItemActiveCalculationResults(String typedId)
typedId
- The typedId of the item, e.g. 34.PLI. Supported type codes are PGI and XPGIObject httpCall(String url, String body) throws XExpression
url
- The full URL to the HTTPS or HTTP endpointbody
- The body of the requestXExpression
- If the HTTP call failshttpCall(String, String, String, String, Map[])
Object boundCall(String uniqueName, String relativeUrl, String body, Boolean... responseBodyAsAString) throws XExpression
Example:
def items = ... def requestBody = [] items.each { item -> def record = [ "name": "Increase", "sku": item.sku, "attribute1": item.newValue, ] requestBody.add([ data: record, oldValues: [:] ]) } def resp = api.boundCall("localhost", "/integrate/PX/batch", api.jsonEncode(requestBody), true)
uniqueName
- The unique name of the bound partitionrelativeUrl
- The relative URL to the Pricefx server command. First slash excluded.body
- The body of the requestresponseBodyAsAString
- If the first param is true, the body is not converted to JSON but returned as a StringXExpression
- If the bound partition is not set or the call failsObject getBoundPartitionNames()
Object httpCall(String url, String body, String methodType, String contentType, Map... properties) throws XExpression
url
- The full URL to the HTTPS or HTTP endpointbody
- The body of the requestmethodType
- "Get"
or "Post"
contentType
- "JSON"
"XML"
or any full content type, for instance "text/plain"
properties
- The map of properties. The following are allowed:
String
value - User name for basic authenticationString
value - User password for basic authenticationboolean
value - Ignores invalid certificates. Use for testing HTTPS connections only. Not for production use.String
value - User name for proxy (if any)String
value - User password for proxy (if any)String
value - Full URL to proxyMap
value - Sub-map that will then add these headers verbatim to the requestXExpression
- If the HTTP call failsObject add(String typeCode, Map<String,Object> values)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API).
Example 1:
def entry = [ lookupTableName : "ExchangeRates", key1 : "USD", key2 : "EUR", attribute1 : 0.879 ] api.add("MLTV2", entry)
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
values
- The key-value pairs representing fields of the object you want to add. Note that all significant fields have to be present.null
if error occurredaddOrUpdate(String, Map)
,
update(String, Map)
,
delete(String, Map)
Object addOrUpdate(String typeCode, Map<String,Object> values)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API). This method also works with the Post Step Logic Formula in workflows.
Example 1:
def entry = [ lookupTableName : "ExchangeRates", key1 : "USD", key2 : "EUR", attribute1 : 0.879 ] api.add("MLTV2", entry)
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
values
- The key-value pairs representing fields of the object you want to add or update. Note that all significant fields have to be present.add(String, Map)
,
update(String, Map)
,
delete(String, Map)
Object update(String typeCode, Map<String,Object> values)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API).
Example 1:
Example 2:api.addOrUpdate("PX", [ "name": "Scoring_MM", "sku": sku ])
Example 3:api.addOrUpdate("PGI", [ "priceGridName" : "LifeCycleMonitor", "sku" : currentItem.sku, "label" : currentItem.label ])
def large = [ "lookupTableId" : pp.id, "lookupTableName" : pp.uniqueName, "name" : "L", "attribute1" : percentileHigh, "attribute2" : "999999999" ] api.addOrUpdate("MLTV", large)
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
values
- The key-value pairs representing fields of the object you want to update. Note that all significant fields have to be present.null
if error occuredaddOrUpdate(String, Map)
,
add(String, Map)
,
delete(String, Map)
Object delete(String typeCode, Map<String,Object> values)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API).
Example:
api.delete("PX", ["id": existingRecord, "name": "ActivePrice"])
typeCode
- A type code string of the type of the object to search for. All available type codes can be retrieved by calling <hostname>/pricefx/<partition name>/fetch
values
- The key-value pairs representing significant fields of the object you want to delete. Note that all significant fields have to be present, if not the ID has to be presentnull
if error occuredaddOrUpdate(String, Map)
,
add(String, Map)
,
update(String, Map)
void sendEmail(String to, String subject, String message)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API).
Example:
def message = "The cost is missing" def filter = Filter.equals("name", "Costs") api.findLookupTableValues("EmailNotifications", filter).each { api.sendEmail(it.value, "Missing costs", message) }
to
- The email address the email is sent tosubject
- The email subjectmessage
- The email bodyvoid customEvent(Object object)
Note: This operation will only work in contexts that allow object modification (CFS, CF and direct formula execution via JSON API). To enable sending of this type of events, this needs to be enabled on the Partition by the system admin (event type "CUSTOM" in the Event Bitmask).
object
- The object to pass along with the eventvoid customEvent(Object object, String customEventType)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API). To enable sending of this type of events, this needs to be enabled on the Partition by the system admin (event type "CUSTOM" in the Event Bitmask).
object
- The object to pass along with the eventcustomEventType
- A custom string to classify the custom event type (as the general event type is always CUSTOM)void customEvent(Object object, String customEventType, String operation)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API). To enable sending of this type of events, this needs to be enabled on the Partition by the system admin (event type "CUSTOM" in the Event Bitmask).
object
- The object to pass along with the eventcustomEventType
- A custom string to classify the custom event type (as the general event type is always CUSTOM)operation
- One of these strings: UPDATE, DELETE, ADD, ITEMCHANGEvoid customEvent(Object object, String customEventType, String operation, boolean omitNullValues)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API). To enable sending of this type of events, this needs to be enabled on the Partition by the system admin (event type "CUSTOM" in the Event Bitmask).
object
- The object to pass along with the eventcustomEventType
- A custom string to classify the custom event type (as the general event type is always CUSTOM). Can be null.operation
- One of these strings: UPDATE, DELETE, ADD, ITEMCHANGE. Can be null.omitNullValues
- Also includes keys that have a null value (false) or omits them (true). True is the default for other method signatures that do not explicitly specify that value.Object updateCalculableObjectHeader(String calcObjTypeCode, String calcObjName)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct formula execution via JSON API).
calcObjTypeCode
- The type code of the object to updatecalcObjName
- The (numeric) ID of the object to updateAttributedResult attributedResult(Object result)
AttributedResult
object to be returned as a result of an output element.
Since AttributedResult
is configurable, it is used when it is not sufficient to only return a
plain value, but it is also required to adjust formatting, e.g. color, underline, etc.
The usage is simple, instead of returning the output value, create a new AttributedResult
instance like this:
api.attributedResult(plain value)
, customize it by calling its various methods, and return it finally.
Example:
def cost = api.getElement("Margin_pct") return api.attributedResult(cost) .withBackgroundColor(cost < 0.30 ? "red" : "#0101DF") .withSuffix(cost < 0.30 ? "!!!" : null) .withTextColor(cost < 0.30 ? "white" : null) .withTextDecoration(cost < 0.30 ? "underline" : null)
result
- The calculation resultAttributedResult - for details on formatting
WrappedResult wrap(Object result)
result
- The resultResultMatrix newMatrix()
The individual cells can be styled via the use of: - linkCell(Object value, String targetPage, String targetPageState) - imageCell(Object imageUrl) - styledCell(Object value, String textColor, String bgColor, String weight, String alignment) - styledCell(Object value, String textColor, String bgColor, String weight) - styledCell(Object value, String textColor, String bgColor) - setColumnFormat(String column, FieldFormatType fft) Valid FieldFormatTypes are: NUMERIC, NUMERIC_LONG, MONEY, PERCENT, TEXT, MONEY_EUR, MONEY_USD, MONEY_GBP, MONEY_JPY, MONEY_CHF, MONEY_PLN, DATETIME, DATE, INTEGER
Example:
def getTrafficColor(value) { if (value <= 0) { return "red" } else if (value > 0 && value < 0.1) { return "yellow" } else if (value >= 0.1) { return "green" } } // initialize new matrix with three columns def matrix = api.newMatrix("Item", "Quantity", "Price", "Pricegrid", "Pricelist", "Margin Status", "Image", "CustomerId") // add more columns dynamically matrix.addColumn("Margin %") matrix.addColumn("Url") // set column formats matrix.setColumnFormat("Item", FieldFormatType.TEXT) matrix.setColumnFormat("Quantity", FieldFormatType.NUMERIC_LONG) matrix.setColumnFormat("Price", FieldFormatType.MONEY_EUR) matrix.setColumnFormat("Margin %", FieldFormatType.PERCENT) matrix.setColumnFormat("Url", FieldFormatType.LINK) // allow users to filter values matrix.setEnableClientFilter(true) // add data row matrix.addRow([ "Item": matrix.styledCell("Red bold text", "#ff0000", "transparent", "bold"), "Quantity": 1.23456, "Price": 78.9012, "Margin %": 0.3456, "Url": "<a href=\"https://www.google.com/search?q=price+f(x)\">link</a>", // optionally you can add link to a price grid of a given ID "Pricegrid" : matrix.linkToPriceGrid("Open Pricegrid", 123, null), // or to a price list of a given ID "Pricelist" : matrix.linkToPriceList("Open Pricelist", 123, null), // or a to custom page (result identical to the previous) "CustomerId" : matrix.linkCell("Open Customer", "customersPage", "123456"), // or add a library images, such as Traffic, BlackTraffic or Arrow "Margin Status" : matrix.libraryImage("BlackTraffic", getTrafficColor(-0.2f)), // or add a general image "Image" : matrix.imageCell("images/grid/approve.png"), ]) return matrix
newMatrix(String...)
ResultMatrix newMatrix(String... columns)
newMatrix()
.columns
- The initial set of columns for the result matrixnewMatrix()
ResultMatrix newMatrix(Collection<String> columns)
newMatrix()
.columns
- The initial set of columns for the result matrixnewMatrix(String...)
,
newMatrix()
ResultGauge newGauge()
Example:
def gauge = api.newGauge() gauge.addSector(5, "#FF0000") gauge.addSector(25, "#FFFF00") gauge.addSector(null, "#00FF00") gauge.setValue(10)
DashboardController newController()
Example:
def lookupTable = api.findLookupTable("SalesOrg") def controller = api.newController() controller.addButton("1. STEP: Change Price Strategy", "pricingParametersPage", lookupTable.typedId) controller.addHTML("<h2>Meatball</h2>")
Filter walkFilter(Filter filter, Closure<?> visitBefore, Closure<?> visitAfter, boolean removeNulls)
removeNulls
is consulted only in case of
(sub)filters which take a list of sub-filters.
Hence, this method may be used in many cases. For instance, you can use it for mapping the current property set to another one, e.g. to convert a PB filter to a PA one. Similarly to this example:
def propertyMappings = ["sku": "ProductID"] api.walkFilter(pbFilter, null, { filter -> if (filter != null && propertyMappings[filter.property] != null) { filter.property = propertyMappings[filter.property] } filter }, false);
filter
- The filter objectvisitBefore
- The before closurevisitAfter
- The after closureremoveNulls
- Removes nullsObject findDataLoad(String dataLoadLabel, String dataLoadType, String target)
dataLoadLabel
- The label of DMDataLoad as seen in the Data Load UIdataLoadType
- The load type of DMDataLoad as seen in the Data Load UI. Namely:
target
- The target of DMDataLoad as seen in the Data Load UIObject findRebateRecordLoad(String rebateRecordLoadLabel)
rebateRecordLoadLabel
- The label of the rebate record load as seen in the Rebate Record UIString currentPartitionName()
DateTimeZone getTimeZone(String tzString)
Example 1:
def timezone1 = api.getTimeZone("Europe/Berlin") def timezone2 = api.getTimeZone("Europe/Prague") def timezone3 = api.getTimeZone("America/New_York") def timezone4 = api.getTimeZone("Australia/Brisbane")
Example 2:
def startHour = 20 def offset = api.getTimeZone("Europe/Prague").getOffset(new Date().getTime()) def startHourUTC = startHour - offset.intValue()
tzString
- The timezone StringString uuid(int len)
Example:
return uuid(15) // returns e.g. "VcydxgltxrVZSTV"
len
- The desired number of charactersString uuid(int len, int radix)
Examples:
return uuid(8, 2) // returns e.g. "01001010" (8 character ID, base=2) return uuid(8, 10) // returns e.g. "47473046" (8 character ID, base=10) return uuid(8, 16) // returns e.g. "098F4D35" (8 character ID, base=16)
len
- The desired number of charactersradix
- The number of allowable values for each character (must be <=62)String uuid()
Example:
return api.uuid() // returns e.g. "92329D39-6F5C-4520-ABFC-AAB64544E172"
MultiKey<Object> multiKey(Object... keys)
keys
- Key valuesMap<String,String> roles()
String entityRef(PartitionedObject po) throws IllegalAccessException
po
- The object of a typedCode P, C, DCR, Q, CT, RBAIllegalAccessException
- If po
is of a different typeCodedouble evalExpression(String mathExpression)
+
-
*
/
^
sqrt
Example:
evalExpression("((10 - 3^2 + 1) * -sqrt(1 * 2 + 3 * 4)) / 4")
mathExpression
- The mathematical expressionvoid setSharedCache(String key, String value)
key
- The cache keyvalue
- The value to storegetSharedCache(String)
,
removeSharedCache(String)
String getSharedCache(String key)
key
- The cache keynull
found in the shared cachegetSharedCache(String)
void removeSharedCache(String key)
key
- The cache keysetSharedCache(String, String)
String base64Encode(String string)
Example:
api.base64Encode("Price f(x)") // "UHJpY2UgZih4KQ=="
string
- The plain text to be encodedbase64Decode(String)
,
https://en.wikipedia.org/wiki/Base64String base64Decode(String base64String)
Example:
api.base64Decode("UHJpY2UgZih4KQ==") // "Price f(x)"
base64String
- The base64 encoded textbase64Encode(String)
,
https://en.wikipedia.org/wiki/Base64List<?> getProductReferences(String typeCode, Set<String> skus)
typeCode
- Currently, only "Q" or "RBA" are supportedskus
- A set of SKU strings that should be searched forString getLocale()
String getBaseURL()
Example:
api.getBaseURL() // "https://www.pricefx.eu"
CreationWorkflowDefinition newCreationWorkflow()
CreationWorkflowStepDefinition newCreationWorkflowStep()
Map<String,List<String>> findNextRevUNs(String typeCode, String... uniqueNames)
typeCode
- Can be one of: 'Q', 'CT', 'RBA'uniqueNames
- List of uniqueNamesClaimContext getClaimContext()
Boolean isFullListCalculation()
Note: Currently only applicable for price grid calculations.
null
is returned if method is not applicableLong triggerPriceGridCalculation(Long priceGridId, Map<String,Object> parameters)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct logic execution via JSON API).
priceGridId
- The ID of the price grid to calculateparameters
- Optional job parametersLong triggerCFSCalculation(Long cfsID)
Note: This operation will only work in contexts that allow object modification (CFS, CalculationFlow and direct logic execution via JSON API).
cfsID
- The ID of CalculatedFieldSetCopyright © 2019. All rights reserved.