The default Business Function operation is the 'JavaScript Function' and displays as 'JavaScriptBusinessFunctionWithBinds' on the Function tab. This operation allows users to define their own functions using JavaScript while binding various STEP data for use.
To add the JavaScript to this operation, click the Edit Business Function link.
For more information on editing a business function, see the Editing a Business Rule topic in the Business Rules documentation here.
Configuration
In this section, you will find an example of how to configure a Business Function that displays the text of a referenced object's attribute value description.
Note: The dynamic binds available for business functions are 'STEP Manager' and 'Logger.'
For more information on STEP JavaScript Binds, see the JavaScript Binds topic (here) as well as the Adding a Bind topic (here) in the Resource Materials online help.
Note: Use caution when changing an input parameter type for an active JavaScript Function business rule. Business rules that call the modified function may also need updating.
Using the provided example, when a user calls this Business Function, they must provide an attribute, references, or a product, which are passed as objects.
Note:
Use caution when changing a return type for an active JavaScript Function business rule. Business rules that call the modified function may also need updating.
Also, it is important to note that JavaScript Business Functions configured to return either a 'Double' or an 'Integer' or lists of these types should be specified in the return command rather than relying on the JavaScript to Java type conversion. For example, to return an integer value of 3 use:
return new java.lang.Integer(3);
return 3;
var referencesArray = product.getReferences(accReferenceType).toArray();
var desc = "";
for (var i = 0; i < referencesArray.length; i++){
var accessoryDesc = referencesArray[i].getTarget().getValue(accDescAttribute.getID()).getSimpleValue();
if (accessoryDesc != null){
if (i != 0){
desc += ", ";
}
desc += accessoryDesc;
}
}
return "Compliant accessories: " + (desc.length == 0 ? "None" : desc);
See the Calling a Business Function from a JavaScript Business Rule topic for information on executing and testing business functions here.
2020, Stibo Systems – Confidential