Create Automation with Scripting

You write Groovy scripts using Application Composer's expression builder.

Server Scripts

In the Server Scripts node, you can use Groovy scripting and web service calls to automate actions that fit your business process. Within this node you can create Validations, Triggers, or Object Functions.

Validations

  • Use validations to define a condition. If the condition isn't met, ensure that you create an error message that guides the user to the correct action.
  • Validations can be either Object Rules or Field Rules.
  • An object rule is invoked when the user clicks Save. It then checks the condition to determine if the error message should be displayed.
  • A field rule is invoked when the value of the selected field changes. It then checks the condition to determine if the error message should be displayed.

Triggers

Triggers are scripts that you can write to complement the default processing logic for a standard or configured object. You create triggers from the Server Scripts node in Application Composer.

Triggers update a change order based on the defined condition.

Triggers are of two types:
  • Object Triggers
  • Field Trigger

Object Triggers

An Object Trigger is invoked when you click Save or Save and Close. The only supported object trigger for change orders is After Changes Posted to Database.

This image displays an object trigger

This image shows object triggers

Field Triggers

A field trigger is invoked when the value of the selected field changes.

Example

Let's say you want to automatically set the Priority of the change order to Urgent when the Reason Code is set to Error. Create a trigger that runs the following Groovy script:

Copy if (ReasonCode == "ERROR"){ setAttribute("PriorityCode", 'URGENT') }

Note: The internal names of Reason Code and Priority Code are used in the code. The values associated with ReasonCode and PriorityCode are the Lookup Code for each value. You can find these values in the Manage Change Reasons and Manage Change Priorities setup tasks in Setup and Maintenance task.
Note:
  • Avoid parallel updates to change header attributes by triggers and global functions. For example, if your object-level or field-level triggers attempt to update header attributes while web service calls (invoked through global functions as part of entry-exit criteria) also attempt to update these attributes, modifications made by the triggers may not get saved because the web service calls would have bumped up the object version.
  • The content in this topic for Triggers is also applicable for these objects: quality issues, and actions, ideas, concepts, requirements, and proposals.
.

Object Functions

Object functions are used by Actions as discussed in the Actions and Links section.

Note: Only change order actions and Application Composer triggers that are described in these sections are supported.