Define Notification Scripts

Define the Groovy scripts for the notifications.

Note: For your reference, you can use the sample scripts and related details that we provide in the Sample Notification Scripts topic as you work through this procedure. These scripts are provided as examples only; your own business requirements may be different from what these samples provide.
  1. Ensure you're working in an active sandbox.

  2. From the Tools menu, select Application Composer.

  3. In the navigation tree, expand Standard Objects, expand the object you want, and then click Server Scripts.

    Example: Standard Objects > Account > Server Scripts.

  4. Click the Triggers tab on the Server Scripts page.

  5. Click the add icon.

  6. In the Create Trigger Object page, create the Groovy trigger:

    1. In the Trigger field, select the trigger type.

      Example: Before Insert in Database

    2. Enter a name for the trigger.

      Example: Account Owner Changed

    3. Add a description.

      Example: Sends a notification when the owner of an account is changed.

    4. Enter the trigger Definition details. When you create a Groovy script, you need the API names of the fields you're trying to access. Create your triggers based on parent/child fields, with these steps:

      1. In the Trigger Definition section's toolbar, click the Show/Hide Expression Palette icon.

      2. Click the Fields tab.

      3. Select an Object.

      4. Click the arrow to collapse the Object area and expand the fields area for the object you selected. The fields for the selected object are displayed.

      5. Select the API you want, and click Insert.

      6. To close the expression palette, click the Show/Hide Expression Palette icon.

        The isAttributeChanged() function works only for the Before trigger types. The workaround for the After trigger types involves retrieving the old value before the database is updated, then retrieving the new value after the update, and then comparing the two values to see whether the attribute is changed. However, this workaround works only for high-level attributes such as CriticalFlag and Status and not for the ViewRow attribute.

  7. In the Edit Script area, add a Groovy script.

  8. Click Save and Close.

  9. Test your changes and publish the sandbox.