Trigger rules specify conditions under which predefined actions must be performed on incoming change requests. These are useful for calling actions after the change requests are created, especially for performing actions in other modules or in third-party applications.
You can build trigger actions with custom functions.
Before you write custom functions for change triggers, we recommend that you learn how to configure and use change triggers in ServiceDesk Plus Cloud.
To write a custom function that can be used as change trigger action, follow the steps given below:
Go to Setup >> Developer Space > Custom Functions > Changes >> Trigger Action. (You can alternately write the custom function while creating/editing a change trigger.)
Click New Custom Function.
Provide a name and description for your custom function.
Write the custom function on the Deluge Script Editor by using the following pointers and then save the function:
As demonstrated in the following screenshot, 'changeObj' is passed as the input argument for the custom functions used in change triggers.

'changeObj' contains the details of the change request on which the trigger must act. The custom function returns a 'void' value.
Let's consider a sample script to add a pre-configured rollout plan to a change request. As a prerequisite, you must configure an additional field with the rollout plan in a change template. When a change request is created using the template, the rollout plan supplied in the additional field will be automatically updated to the Rollout Plan field in the change request.
After writing the custom function, you can test run it by following the steps given below:
Click Save & Execute Script.
Choose a sample change request from the list of change requests displayed and click Next.
The data that will be passed to the custom function will be displayed under the parameter 'changeObj'. Optionally, you can modify the 'changeObj' values. Click Execute.
The script will be executed, and the output will be displayed.
When you test a custom function, you can debug the code and print the output by using a statement called info. For example, to understand the structure of 'changeObj' and 'context', you can simply run the following script and study the response.