Calculated Attribute expressions can be written using the following available functions. Examples follow the Available Functions table.
Note: Adding a new line by pressing the Enter key or adding "\n" within the Function Editor template allows the resulting values to display in multiple lines.
For more extended scenarios and function templates, see the available Calculated Attribute Use Case Examples in the Calculated Attributes section of the System Setup / Super User Guide documentation here.
Also refer to the Insert Templates topic in the System Setup / Super User Guide documentation for more information here.
Available Functions
|
Other Function |
Parameters |
Description |
|---|---|---|
|
OR |
(condition1, condition2, ...) |
Returns TRUE (=1) if one of the supplied conditions is true; otherwise returns FALSE (=0). |
|
AND |
(condition1, condition2, ...) |
Returns TRUE (=1), if all the supplied conditions are true; otherwise returns FALSE (=0). |
|
NOT |
(condition) |
Returns TRUE (=1) if condition is false; otherwise returns FALSE (=0). |
|
STEPID |
() |
Returns the ID of the current object. |
|
STEPNAME |
() |
Returns the name of the current object. |
|
STEPNAME |
('url') |
Returns the name of the object pointed to by ‘url’. |
|
STEPURL |
() |
Returns the STEP URL of the current object. |
|
STEPURL |
('object-type', 'object-id') |
Returns the STEP URL of the object with ID ‘object-id’ and of type ‘object-type’. The object type could be product, classification, entity, asset, attribute, etc. |
|
STEPURL2OBJID |
('url') |
Returns the internal object representation of the object pointed to by ‘url’. Note: This function must be used in combination with a LIST or ITERATE function. |
|
STEPOBJECTTYPE |
() |
Returns the STEP name of the object type of the current object. |
|
STEPOBJECTTYPE |
('url') |
Returns the STEP name of the object type of the object pointed to by 'url'. |
|
CHILDREN |
() |
Returns true children (not links) of an asset, a classification, an entity, a product, or a product-override. Similar to SUBPRODUCTS, but this function returns more than products. Note: This function must be used in combination with a LIST or ITERATE function. |
|
SUBPRODUCTS |
() |
Returns sub products of a product, product-override, or classification. Similar to CHILDREN, but this function returns only products. Note: This function must be used in combination with a LIST or ITERATE function. |
|
CLASSIFICATIONS |
([link-type]) |
Returns the names and/or IDs of the classifications of an asset, a product, or a product-override (classifications of product-overrides + classifications of overridden product) of the specified 'link-type'. [link-type] is optional. |
|
CLASSIFICATIONPRODUCTLINKS |
([link-type]) |
Returns the metadata values placed on the links between an object and classification of the specified 'link-type'. [link-type] is optional, all are returned if not specified. |
|
CPLCLASSIFICATION |
() |
Returns the classification object from a classification-product link. |
|
CPLPRODUCT |
() |
Returns the product object from a classification-product link. |
|
DATACONTAINERS |
([data-container-type]) |
Return data container objects of current composite object. Return all data containers of data container type with ID 'data-container-type' (all if not specified). |
|
DATACONTAINERCOMPOSITE |
() |
Return composite object of current data container object. |
|
DATACONTAINERTYPEID |
() |
Return ID of data container type of current data container |
|
REFERENCES |
([object-type[, reference-type]]) |
Returns the references to objects of type ‘object-type’ and with the reference type ‘reference-type’. Object-type could be product, classification, entity, or asset. [object-type] and [reference-type] are optional, all are returned if not specified or blank. |
|
REFERENCESTO |
([object-type[, reference-type]]) |
Returns the references pointing to this object from objects of type ‘object-type’ and with specified reference type. Object-type could be product, classification, entity, or asset. [object-type] and [reference-type] are optional, all are returned if not specified or blank. |
|
REFERENCETARGET |
() |
Returns the target (destination) object of reference. |
|
REFERENCEOWNER |
() |
Returns the owner of the reference. |
|
REFERENCETYPEID |
() |
Returns the ID of the reference type. |
|
PARENTID |
() |
Returns the parent ID if node is a tree node. |
|
PATH |
() |
Returns the parent path of a product, entity, or a classification. The path shows the top node in the tree as the first element and the current object is the last element. |
|
ISBELOW |
(url) |
Returns TRUE (=1) if the object pointed to by ‘url’ is in the parent path of the current object. |
|
REVISIONS |
() |
Returns the list of all revision objects for the current object. The revisions are displayed with the first revision object first and the most recent revision object last. Note: This function must be used in combination with a LIST or ITERATE function. |
|
REVISIONNAME |
() |
Returns the name of the current revision (or most recent revision of current object). The revision number is shown as '0.1', '1.0', etc. |
|
REVISIONEDITEDBY |
() |
Returns the name of the user responsible for the change in the current revision (or most recent revision of current object). |
|
REVISIONCOMMENT |
() |
Returns the comment of the current revision (or the most recent revision of current object). |
|
REVISIONISMAJOR |
() |
Returns the Boolean TRUE (=1) or FALSE (=0) to indicate if the current revision (or most recent revision of current object) is a major revision or not. |
|
REVISIONCREATEDATE |
() |
Returns the creation date of the current revision (or most recent revision of current object). The date is returned in ISO format "YYYY-MM-DD HH:MM:SS". |
|
REVISIONEDITDATE |
() |
Returns the last edit date of the current revision (or most recent revision of current object). The date is returned in ISO format "YYYY-MM-DD HH:MM:SS". |
|
FIRSTREVISIONCREATEDATE |
() |
Returns the creation date of the first revision (not the initial revision which could have been purged). The date is returned in ISO format "YYYY-MM-DD HH:MM:SS". |
|
OVERRIDDENPRODUCT |
(product-override-id) |
Returns the ID of the overridden product for the product override with supplied ID. Returns N/A if the object is not an overridden product. |
|
OVERRIDDENPRODUCTOBJECT |
() |
Returns the product being overridden by the current product override. Returns an empty value if the object has no overridden product. |
|
OVERRIDDENBY |
() |
Returns the product overrides for the current product. Returns an empty list if the object is not overridden. |
|
PRODUCTOVERRIDEPARENTS |
() |
Returns the product overrides having this product as child. Returns an empty list if the object is not linked into any product overrides. |
|
REPLACEVALUEBYLOOKUP |
(asset-id, value) |
Returns the 'value' substituted by using the transformation lookup table referred to in 'asset-id'. For more information, see the Creating a Transformation Lookup Table section of the Data Quality documentation here. |
|
REPLACEWORDBYLOOKUP |
(asset-id, words) |
Returns what each word in 'words' is substituted by, using the transformation lookup table referred to in 'asset-id'. For more information, see the Transformation Lookup Tables section of the Data Quality documentation here. |
|
COMPLETENESS |
([completeness-metric-id]) |
Returns the completeness score of the current object as a percentage (decimal number between 0 and 100). If completeness does not make sense for the current object, an empty string is returned. [completeness-metric-id] is optional. The default completeness metric is used if none is supplied. For more information, see Setting Up Completeness Metrics in the Data Quality documentation here. |
|
PACKAGINGHIERARCHYCHILDLINKS |
() |
Returns the packaging hierarchy child links of the current product. |
|
PACKAGINGHIERARCHYPARENTLINKS |
() |
Returns the packaging hierarchy parent links of the current product. |
|
PHLCHILD |
() |
Returns the child product of the current packaging hierarchy link. |
|
PHLPARENT |
() |
Returns the parent product of the current packaging hierarchy link. |
|
PHLQUANTITY |
() |
Returns the quantity of the current packaging hierarchy link. |
|
WORKFLOWIDS |
() |
Return the list of workflow IDs for the STEP workflows that include the object. |
|
CURRENTWORKFLOWSTATES |
(workflow-id) |
Returns the list of IDs for the STEP workflow states that include the current object for the supplied 'workflow-id'. |
Use Cases
For an example using overrides, see Use Case: Calculated Attribute for Overrides here.
For an example using classifications, see Use Case: Calculated Attribute for Classifications here.
For an example using classifications, see Use Case: Calculated Attribute for References here.
Examples
The examples below assume a setup including these attributes and products:
|
ATTRIBUTE Type |
ID |
Name |
AttrDesc |
|---|---|---|---|
|
Text-validated product attribute |
TEXT1id |
TEXT1 |
TEXT1 description |
|
Number-validated product attribute with length units |
NUMBER1id |
NUMBER1 |
NUMBER1 description |
|
Embedded number-validated product attribute with length units |
EMBEDDEDNUMBER1id |
EMBEDDEDNUMBER1 |
EMBEDDEDNUMBER1 description |
|
Text-validated attribute property |
AttrDescid |
AttrDesc1 |
AttrDesc description |
|
LOV-validated product attribute |
LOVAttr1id |
LOVAttr1 |
LOV description |
|
LOV with 'Use IDs on Values' = Yes; and Values =Yes and No |
LOV1id |
LOV1 |
|
|
PRODUCTS ID |
Name |
Parent |
TEXT1id |
NUMBER1id |
|---|---|---|---|---|
|
P-family-id |
P-family |
Product hierarchy root |
family value |
2 m |
|
P1id |
P1 |
P-family-id |
p1 value |
4 m |
|
P2id |
P2 |
P-family-id |
p2 value |
5 m |
|
P3id |
P3 |
P-family-id |
p3 value |
6 m |
Copy and paste any of the following examples into the Function Editor and then evaluate against the specified object to get the defined result.
or((value('TEXT1id')= 'p1 value'), (value('NUMBER1id')= '4')) // = 1 (TRUE) evaluated P1idor((value('TEXT1id')= 'p0 value'), (value('NUMBER1id')= '3')) // = 0 (FALSE) evaluated P1idand((value('TEXT1id')= 'p1 value'), (value('NUMBER1id')= '4')) // = 1 (TRUE) evaluated P1idand((value('TEXT1id')= 'p0 value'), (value('NUMBER1id')= '3')) // = 0 (FALSE) evaluated P1idnot(value('TEXT1id')= 'p1 value')) // = 0 (FALSE) evaluated P1idnot(value('TEXT1id')= 'p0 value')) // = 1 (TRUE) evaluated P1idstepid() // = 'P1id' evaluated P1idstepname() // = 'P1' evaluated P1idstepname('step://product?id=P1id') // = 'P1' evaluated P1idstepurl() // = 'step://product?id=P1id' evaluated P1idstepurl('Product','P1id') // = 'step://product?id=P1id' evaluated P1idstepobjecttype() // = 'Item' evaluated P1idstepobjecttype('step://product?id=P1id') // = 'Item' evaluated P1iditerate(stepurl2objid(stepurl('Product','Level1-109267')),'stepname()')// = 'P1id' evaluated on some product node.
list(iterate(children(),'concatenate(stepname())'),', ') // = 'P1, P2, P3' evaluated P-Family since these are productslist(iterate(subproducts(),'concatenate(stepname())'),', ') // = 'P1, P2, P3' evaluated P-Family since these are productslist(iterate(children(),'concatenate(stepname())'),', ') // = 'E1, E2, E3' evaluated entity with three children, none of which are productslist(iterate(subproducts(),'concatenate(stepname())'),', ') // = '' evaluated entity with three children, none of which are productslist(iterate(iterate(references('product', 'BillOfMaterials'),'referencetarget()'),'stepname()'),', ') // = 'P3' evaluated against P1 when P1 has a BillOfMaterials reference to P3parentid() // = 'P-family' evaluated P1id list(iterate(path(),'concatenate(stepname())'),', ') // = 'Primary Product Hierarchy, Products, P-family' evaluated P-Family isbelow('step://product?id=P1id') // = 0 (FALSE) evaluated P-Familyisbelow('step://product?id=P-Family') // = 1 (TRUE) evaluated P1idlist(iterate(revisions(), 'revisioncreatedate()'), ', ') // = '2016-04-20 17:18:42, 2016-04-22 09:44:36, 2016-04-25 09:34:36, 2016-05-06 11:04:09' evaluated P-Family
revisionname() // = '0.3' evaluated P-Familyrevisioneditedby() // = 'USER' evaluated P-Familyrevisioncomment() // = 'Auto Generated' evaluated P-Familyrevisionismajor() // = '0' (FALSE) evaluated P-Familyrevisioncreatedate() // = '2016-04-25 09:34:36' evaluated P-Familyrevisioneditdate() // = '2016-04-25 16:16:30' evaluated P1firstrevisioncreatedate() // = '2016-04-20 17:20:41' evaluated P1completeness() // = '51.282051282051284601948282215744' evaluated P1 round(completeness(),0) // = '51' evaluated P1 workflowids() // = 'ItemCreationOrderProcessWorkflow' evaluated P1 (2 workflows returned: Item Creation and Order Process Workflow)currentworkflowstates('OrderProcessWorkflow') // = 'State-2' evaluated P1 list(iterate(classifications(), "stepid()"), "/ ") // = Classification1/ Classification2 evaluated product that exists in two classifications
{meta := iterate(stepurl2objid(stepurl('attribute','TEXT1id')), 'value("Attribute Description")'),val := value('TEXT1id')}concatenate("\'", meta,"\'", " is the metadata on the \'TEXT1id\' attribute which contains the value: ", val) /* "'TEXT1 description' is the metadata on the 'TEXT1id' attribute which contains the value: family value" evaluated P-family*/
|
Template |
Results |
|---|---|
overriddenproduct('BatteriesOverride1ID')
|
Evaluated on Batteries Override 1: Batteries
|
overriddenproduct('Batteries')
|
Evaluated on Batteries Override 1: N/A
|
{x := listlen(overriddenby()),z := iterate(overriddenby(), 'stepname()'), z := list2multivalue(z), z := substitute(z, "<multisep/>", " ") } concatenate("This product is overridden by ", x, ", product override(s):", z) |
Evaluated on Batteries: This product is overridden by 3 product override(s): Batteries Override 2 Batteries Override 1 Batteries Override 3 |
{x := iterate(overriddenproductobject(), 'stepname()'),z := listitem(x,1) } concatenate('This PO overrides the product "', z, '"')
|
Evaluated on Batteries Override 1: This PO overrides the product "Batteries"
|
list(iterate(productoverrideparents(), "stepid()"), "/ ")
|
Evaluated on Battery Items: BatteriesOverride2ID/BatteriesOverride1ID/BatteriesOverride3ID
|
|
Asset: UOMLookupTable |
|||
|---|---|---|---|
|
From |
EACH |
DOZEN |
CASE |
|
To |
Ea. |
Dz. |
Case |
REPLACEVALUEBYLOOKUP('UOMLookupTable','EACH') // = 'Ea.' evaluated P1 REPLACEWORDBYLOOKUP('UOMLookupTable','EACH, DOZEN, CASE') // ='Ea., Dz., Case' evaluated P1
{i:=path(), parent:=listitem(i,listlen(i)-1)} iterate(parent, 'concatenate("name=",stepname(),"; id=", stepid())') // = 'name=P-family; id=P-family-id' evaluated P1
{all:=iterate(subproducts(), "prodval('BrandName')"),unique:=unique(all),
oftenIndex:=1,
oftenCount:=0,
dummy:=iterate(unique, '
{curval:=item,
count:=listlen(filter(all,"exact(curval,item)"))
}
if (count>oftenCount, concatenate(
oftenCount:=count,
oftenIndex:=index),
0)')
}
if (oftenCount>0, listitem(unique,oftenIndex), "")
Note: Use cautiously. This operation can drain system CPU since all grandchildren are read for each product.
{attrid:='grandchildattrid'}listconcatenate(iterate(subproducts(), 'iterate(subproducts(),"prodval(attrid)")'))
{msg := "Closest Date That Is Less Than The Current Date Is: ",
datenow := left(substitute(now(), "-", ""), 8),
datelist := filter(iterate(children(), 'value("ISODate")'), 'substitute(item, "-", "") <lt/> datenow'),neardate := listitem(reverse(sortnumeric(datelist)), 1)
}
if(exact(neardate, "N/A"), "None Newer", concatenate(msg, neardate))
2017, Stibo Systems