Loading...

Adding an OnStart Script

You can execute Java or JavaScript after the input activities are evaluated, which is useful for validating activity inputs before they are processed in the workflow. If the inputs are invalid, you can perform operations such as failing the activity.

Example

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

  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. On the OnStart Script tab, enter the following code:

    #OnStart Script Sample

    if (activity.userName == null || activity.userName.length() == 0)

    {
    workflow.setFailed("missing username");
    }

    if (activity.email == null || activity.email.length() == 0)
    {
    workflow.setFailed("missing email address");
    }

    Tip: Click Insert Variable to add variables as needed.

  4. Click OK.

Last modified: 9/10/2020 5:37:26 AM