Use Global Functions to Define Change Order Entry and Exit Criteria
You can use global functions when you write Groovy scripts using the expression builder in Application Composer.
- Best practices for working with attributes in global functions.
- How to use the entry and exit criteria to populate approvers.
- Examples that show how global functions can be used with item rules.
Best Practices for Working with Attributes in Global Functions
- Validating attributes
- Validating whether the change tabs and change affected item tabs have content (Has Content)
- Ensure that the validation is successful and doesn't time out. Test the validation with increments of 10 attributes at a time. If the validation takes longer than 10 seconds it will time out.
-
Use the Limit parameter to limit the number of fields that are fetched for a REST call.
Syntax:
?limit=<number>
The value of the Limit parameter is set to 25, in case you don't specify a value for this parameter. If you manually specify a limit value, it will fetch that many records. If you've only a few records, don't specify a high value for the Limit parameter because memory is allocated based on the Limit parameter.
- Check the attribute values of the change extensible flexfields, item
operational attributes, and item extensible flexfields.
- Limit the number of attributes to 10 while validating the values.
- Use the configured objects to perform validations ahead of time. The configured object stores the result, and you use the global function to access the results. This global function is invoked as part of entry and exit criteria.
- Use the query parameters to filter the data rather than iterating
through all the attachments. For example, if you're trying to check
if an affected item has a certain attachment category, attachment
category=Secured Attachment, then you can build your query URL in
the following
way:
/productChangeOrdersV2/<changeId>/child/changeOrderAffectedObject/<itemUniqId>/child/changeOrderAffectedItemAttachment?q=CategoryCode="Secured Attachment".
- Validating whether the tabs on the change and it's affected item have
content (Has Content).
- When working on a "has content" use case, check the array size. If the array size is greater than zero, don't iterate through the result set. For example, you can check the array size for an affected item that has AMLs.
Use Entry and Exit Criteria to Add Approvers
You can define the entry and exit criteria in the Groovy script to add approvers to a workflow. Let's say you want to add approvers based on certain change header attributes. Set the change extensible flexfield attribute Team to Packaging, then add the Packaging_Role attribute as approver to interim approval or approval status.
- Create a configured object that will evaluate Team to change order extensible flexfield attribute and returns the role to be added as an approver.
- Execute the script on a scheduled process (Scheduled Custom Groovy Object Function) to populate the result in a configured attribute.
- Configure entry or exit criteria from Interim Approval 1 to Interim Approval 2 or Interim Approval to Approval that invokes a global function and populates the approvers.