Other Examples

In the sections below, many other calculated attribute functions are grouped by purpose and are demonstrated in simple terms using a variety of value templates:

  • Classification Functions can be used to access classification objects.
  • Completeness Functions can be used to access the completeness score of an object.
  • Data Container Functions can be used to access data container objects.
  • Hierarchy Functions can be used to access STEP hierarchy objects.
  • Lookup Table Functions can be used to access lookup table data.
  • Object Functions can be used to access object information.
  • Override Functions can be used to access product override data.
  • Reference Functions can be used to access object reference data.
  • Revision Functions can be used to access revision information.
  • Workflow Functions can be used to access workflow information.

For function syntax information and links to more detailed use cases, refer to the Other Functions topic in the STEP Functions section of the Resource Materials online help here.

Classification Functions

These functions can be used to access classification objects.

The example calculated attribute is written to use a product with the classification data defined in the following table.

 

References

Product1(P1)

ClassificationA

ClassificationB

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

list(iterate(classifications(), "stepid()"), "/ ")

P1

ClassificationA/ ClassificationB

Use Cases

For a scenario using the CLASSIFICATIONS function, refer to Classification Scenario here.

Completeness Functions

These functions can be used to access the completeness score of an object.

For more information, refer to Initial Setup for Metrics in the System Setup documentation here.

Copy and paste the Value Template text below into the Function Editor, select an object set up for completeness metric, and click the Evaluate button to display the defined Result.

Value Template

Result

completeness()

51.282051282051284601948282215744

round(completeness(),0)

51

Data Container Functions

These functions can be used to access data container objects on products or entities.

The example value templates require the products and values defined in the following table:

Data Container Types (ID):

Non-Typed Data (244320)

Technical Specifications (244321)

Product: ALRM-01 (157618)

Product: ALRM-02 (157619)

{no Non-Typed Data (244320) data container exists}

Value Template

ALRM-01 Result

ALRM-02 Result

{
dclist := datacontainers(),
dc_typeids := iterate(dclist, 'datacontainertypeid()')
}
list(sort(unique(dc_typeids)), "\n")

244320

244321

244321

{
dc := datacontainers(),
dcid := list(iterate(dc, 'value("Supplier_Cost")'), "/"),
dcc := list(iterate(dc, 'datacontainertypeid()'), ", "),
dc1 := listitem(dc, 1),
dc2 := iterate(datacontainercomposite(), 'stepname()'),
msg := ""
}
concatenate(dcid, " --- ", dcc, " --- ", dc2)

0.19/0.28/0.45 --- 244321, 244320, 244320 --- ALRM-01

0.36---244321---ALRM-02

{
dc := datacontainers(),
dcid := sort(unique(iterate(dc, 'value("Supplier_Cost")'))),
introtext := if(listlen(dcid) <gt/> 1, "Supplier Cost ranges
 from ", "Supplier Cost is "),
septext := if(listlen(dcid) <gt/> 1, " to ", ""),

firstval := listitem(dcid,1),
lastval := if(listlen(dcid) <gt/> 1, listitem(dcid, 
listlen(dcid)), ""),
 
dctypes := sort(unique(iterate(dc, 'datacontainertypeid()'))),
dclist := if(listlen(dctypes) <gt/> 1, list(dctypes, ", ",
 " and "), listitem(dctypes,1)),
dctext := if(listlen(dctypes) <gt/> 1, " in Data Container 
types ", " in Data Container type "),
msg := "Data Container examples"
}
concatenate(introtext, firstval, septext, lastval, dctext, dclist)

Supplier Cost ranges from 0.19 to 0.45 in data container types 244320 and 244321.

Supplier Cost is 0.36 in Data Container type 244321

Hierarchy Functions

These functions can be used to access STEP hierarchy objects.

The example value templates require the objects and values defined in the following table:

Object

Parent

TEXT1id

P-family(P-family-id)

Product hierarchy root(PRoot)

product value

P1(P1id)

PFam(P-family-id)

p1 value

P2(P2id)

PFam(P-family-id)

p2 value

P3(P3id)

PFam(P-family-id)

p3 value

E-family(E-family-id)

Entity root(ERoot)

entity value

E1(E1id)

EFam(E-family-id)

e1 value

E2(E2id)

EFam(E-family-id)

e2 value

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

Notes

list(iterate(children(),
'concatenate(stepname())'),', ')

P-family-id

P1, P2, P3

These are products

list(iterate(subproducts(),
'concatenate(stepname())'),', ')

P-family-id

P1, P2, P3

These are products

list(iterate(children(),
'concatenate(stepname())'),', ')

E-family-id

E1, E2

These are entities

list(iterate(subproducts(),
'concatenate(stepname())'),', ')

E-family-id

 

These are entities, not products

parentid()

P1id

P-family

 

list(iterate(path(),
'concatenate(stepname())'),', ')

P-family-id

Primary Product Hierarchy, Products, P-family

 

isbelow('step://product?id=P1id')

P-family-id

0

FALSE

isbelow('step://product?id=P-Family')

P1id

1

TRUE

{i:=path(), 
parent:=listitem(i,listlen(i)-1)
} 
iterate(parent, 
'concatenate("name=",stepname(),"; id=", stepid())')

P1id

name=P-family; id=P-family-id

Use -2 (instead of -1) to get name / ID of grandparent, etc.

Evaluating Data on Child Objects

The example value templates require the products and values defined in the following table:

Parent

Products

BrandNameID

RemovalDate

Product hierarchy root(PRoot)

J-family(J-family-id)

 

 

J-family-id

J1(J1id)

Alpha

2013-05-01

J-family-id

J2(J2id)

Alpha

2014-05-01

J-family-id

J3(J3id)

Alpha

2012-05-01

J-family-id

J4(J4id)

Zeta

 

J-family-id

J5(J5id)

Zeta

2016-05-01

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

Notes

{all:=iterate(subproducts(), "prodval('BrandNameID')"),
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), "")

J-family-id

Alpha

Value for attribute ID 'BrandName' that occurs the most times in its children.

{attrid:='grandchildattrid'
}
listconcatenate(iterate(subproducts(), 
'iterate(subproducts(),"prodval(attrid)")'))

J-family-id

AlphaAlphaAlphaZetaZeta

Use cautiously. This operation can drain system CPU since all grandchildren are read for each product.

{msg := "Closest date that is less than the current date is: ",
datenow := left(substitute(now(), "-", ""), 8),
datelist := filter(iterate(children(), 'value("RemovalDate")'), 
'substitute(item, "-", "") < datenow'),
neardate := listitem(reverse(sortnumeric(datelist)), 1)
}
if(exact(neardate, "N/A"), "None Newer", concatenate(msg, neardate))

J-family-id

Closest date that is less than the current date is: 2016-05-01

Returns the value of 'RemovalDate' attribute on the child objects that is closest to the current date while still less than the current date.

Returns 'None Newer' if no such child exists.

Lookup Table Functions

These functions can be used to access lookup table data.

For more information, refer to the Transformation Lookup Tables topic in the Resource Materials online help here.

The following templates use this lookup table data.

Asset: UOMLookupTable

From

EACH

DOZEN

CASE

To

Ea.

Dz.

Case

The examples in the following table do not require specific object data to produce the defined result. Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.

Value Template

Result

REPLACEVALUEBYLOOKUP('UOMLookupTable','EACH')

Ea.

REPLACEWORDBYLOOKUP('UOMLookupTable','EACH, DOZEN, CASE')

Ea., Dz., Case

Object Functions

These functions can be used to access object information.

The example value templates require the products and values defined in the following table:

Product

Object Type

TEXT1id

TEXT1id Metadata

P-family(P-family-id)

Folder

Family value

Family meta value

P1(P1id)

Item

P1 value

P1 meta value

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

stepid()

P1id

P1id

stepname()

P1id

P1

stepname('step://product?id=P1id')

P1id

P1

stepurl()

P1id

step://product?id=P1id

stepurl('Product','P1id') 

P1id

step://product?id=P1id

stepobjecttype()

P1id

Item

stepobjecttype('step://product?id=P1id')

P1id

Item

iterate(stepurl2objid(stepurl('Product','Level1-109267')),'stepname()')

{any}

P1id

{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) 

P-family-id

'Family meta value' is the metadata on the 'TEXT1id' attribute which contains the value: Family value

Override Functions

These functions can be used to access product override data.

The example calculated attributes below are written to use the hierarchy objects defined in the following table.

Family

Folder

Overrides

Batteries(BatteriesID)

Battery Items(BatteryItemsID)

Override 1(Override1ID)

Override 2(Override2ID)

Override 3(Override3ID)

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Template

Object

Results

overriddenproduct('Override1ID')

Override1ID

Batteries

overriddenproduct('Batteries')

Override1ID

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)

BatteriesID

This product is overridden by 3 product override(s):

Override 2

Override 1

Override 3

{x := iterate(overriddenproductobject(), 'stepname()'),
z := listitem(x,1)
}
concatenate('This PO overrides the product "', z, '"')

Override1ID

This PO overrides the product "Batteries"

list(iterate(productoverrideparents(), "stepid()"), "/ ")

BatteryItemsID

Override2ID/Override1ID/Override3ID

Reference Functions

These functions can be used to access object reference data.

The example calculated attributes below are written to use the referenced object defined in the following table.

Product

Reference Type

Reference Target

P1(P1id)

BillOfMaterials

P3(P3id)

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

list(iterate(iterate(references('product', 
'BillOfMaterials'),'referencetarget()'),'stepname()'),', ')

P1id

P3

Use Cases

For a scenario using the REFERENCES function, refer to Reference Scenario here.

For a scenario using the REFERENCES and REFERENCETARGET functions, refer to Total Cost of Materials Scenario here.

Revision Functions

These functions can be used to access revision information.

The example calculated attributes below are written to use the revisions defined in the following table.

Product

Revision #

Create Date

Edit Date

Major

User

Comment

P-family(P-family-id)

1.1

Wed Jul 12 12:06:16 EDT 2017

Wed Jul 12 12:26:55 EDT 2017

 

USERZ

Complete Approval

P-family(P-family-id)

1.0

Mon May 08 11:34:51 EDT 2016

Tue May 09 15:09:14 EDT 2016

X

USERY

Comment added by user

P-family(P-family-id)

0.1

Mon Jun 15 16:27:04 EDT 2015

Mon Jun 15 16:27:04 EDT 2015

 

USERW

Auto Generated

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

list(iterate(revisions(), 
'revisioncreatedate()'), ', ')

P-family-id

2015-06-15 16:27:04, 2016-05-08 11:34:51, 2017-07-12 12:06:16

revisionname()

P-family-id

1.1

revisioneditedby()

P-family-id

USERZ

revisioncomment()

P-family-id

Complete approval

revisionismajor()

P-family-id

0

revisioncreatedate()

P-family-id

2017-07-12 12:06:16

revisioneditdate()

P-family-id

2017-07-12 12:26:55

firstrevisioncreatedate()

P-family-id

2015-02-13 11:36:39

Workflow Functions

These functions can be used to access workflow information.

The example calculated attributes below are written to use the referenced object defined in the following table.

Product

Current Workflow

Current State

P1(P1id)

Workflow5

State-C

P1(P1id)

Workflow6

State-A

After creating the data above, copy and paste any of the Value Template text below into the Function Editor, select the object with the defined data, and click the Evaluate button to display the Result.

Value Template

Object

Result

workflowids()

P1id

Workflow5Workflow6

currentworkflowstates('Workflow6')

P1id

State-A