Loading...

Adding OnStart and OnComplete Scripts to an Activity

You can execute a script after the activity input values are evaluated or at the end of the activity.

Adding an OnStart Script

You can execute a script written in Java or JavaScript after the activity input values are evaluated. You can validate the activity inputs before they are processed in the Workflow, giving you the chance to perform certain operations when the inputs are not valid (such as failing the activity with a Job Pending reason or calling out a failure email activity).

Example

The create user qcommand activity creates a CommCell user based on input values provided during execution. You can fail the Workflow when the new user values are invalid or missing by setting an OnStart script:

  1. From the workflow design area, right-click the activity and then click Properties.

    The activity property dialog box appears.

  2. Click the OnStart Script tab.
  3. Enter the code to be used.

    Tip: Click Insert Variable to add variables as needed.

  4. Click OK.

Java Example

The following script sample checks whether the username and email values for a new account are missing. If these values are missing, the Workflow fails.

Adding an OnComplete Script

You can execute a script written in Java or JavaScript at the end of an activity. You can verify the activity output before it continues to the next activity and trigger a specific operation in the script depending on the output.

Example

In the Execute activity, there is XML to associate a CommCell user to a user group. Both the user and user group values are provided during execution. You can fail the Workflow when an error code is found in the XML output by setting an OnComplete script:

  1. From the workflow design area, right-click the activity and then click Properties.

    The activity property dialog box appears.

  2. Click the OnComplete Script tab.
  3. Enter the code to be used.

    Tip: Click Insert Variable to add variables as needed.

  4. Click OK.

Java Example

The following script sample checks if the XML executed with no error codes (exit code is not 0). If an error code is found, the Workflow fails.