Define Notification Scripts for Sales

Here's how you define a Groovy script for a notification prompt:

  1. Ensure you're working in an active sandbox.

  2. Click Navigator > Configuration > Application Composer.

  3. In the navigation tree, expand Standard Objects, expand the object you want, and then click Server Scripts. For 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.

      Oracle recommends that you use the trigger type After Changes Posted to Database. This trigger type lets you to stop potential issues if the Groovy script is accidentally written to run indefinitely. If the trigger type is set to Before Update to Database, with a bad script, you may receive errors.

      If you're creating a new object, and you want to trigger a notification when the object is created, Oracle recommends that you use the trigger type Before Insert to Database. However, some of the Before trigger types don't have all attributes exposed yet, resulting in some fields being blank. To debug your triggers if you're not getting the expected results, follow the steps in Debug Your Groovy Scripts.

    2. Enter a name for the trigger.

    3. 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, click Show/Hide Expression Palette.

      2. Click the Fields tab.

      3. Select an Object.

      4. Click the Maximize Edit Script arrow. 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 Restore Edit Script arrow, and then click Show/Hide Expression Palette.

        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. Add a Groovy script. For example, if you're defining the notification for accounts, add the Account Push notification received Groovy script.

  8. Click Save and Close.

  9. Navigate to the Notification Preferences page to configure your preferences for the notifications. See Configure Delivery Preferences and Text for a Notification for more information.

Note: You can reuse a Groovy notification prompt if no other notification uses it.