Adding a Trigger to an Object



Steps:

  1. Hello, my name is John, and today we are discussing extending  applications using Application Composer.

    Step 1
  2. In this demo, I will show you how to create a trigger that prevents the creation of records when the trigger condition is met.

     

    We will use Application Composer's expression builder  to write the Groovy script for the trigger condition.

     

    Step 2
  3. In this example, we are adding the trigger to a custom trouble ticket application used by sales to resolve customer issues.

     

    Salespeople record their attempts to resolve the customer issue on the Activities tab in each trouble ticket.

    Step 3
  4. We are adding the trigger to prevent users from creating activities on closed trouble tickets.

    Step 4
  5. This demo is the first of two demos that show you how to create and test a trigger.

    Step 5

  6. We want to prevent users from creating activities, so we create the trigger on the Activity object. It's a child object of Trouble Ticket.

     

    Click the Expand button.

    Step 6
  7. We create the trigger as part of Server Scripts.

     

    Click the Server Scripts link.

    Step 7
  8. And wew select the Triggers tab.

     

    Click the Triggers tab.

    Step 8
  9. Let's create the trigger.

     

    Click the Add a new Trigger... button.

    Step 9
  10. We want to check the ticket status when the user creates the activity, so we keep the default trigger After Create.

    Step 10

  11. Let's enter an internal name. No spaces permitted.

     

    Enter the desired information into the Trigger Name field. Enter

     "XYonlyIfOpenTT"
    .

    Step 11
  12. And a description.

    Enter the desired information into the Description field. Enter

     a valid value
     e.g.
     "Prevent creation of an activity if the trouble ticket is closed."
    .

    Step 12
  13. To write the script, we'll use the expression builder palette.

    Step 13

  14. Click the Expand Show Palette button.

    Step 14
  15. We'll find the field to evaluate on the Fields tab.

    Click the Fields tab.

    Step 15
  16. We are checking the value of a Trouble Ticket field in our script, so let's expand the Activity object.

     

    Click the Expand button.

    Step 16
  17. And we select Trouble Ticket to view its fields.

    Click the Trouble Ticket object.

    Step 17
  18. Now let's find the Status field.

    Click the button of the scrollbar.

    Step 18
  19. Click the Status cell.

    Step 19
  20. Let's enter the first part of our script.

     

    Enter the desired information into the Expression field. Enter

     a valid value
     e.g.
     "if("
    .

    Step 20
  21. Click the Insert button.

    Step 21
  22. Click in the Expression field.

    Step 22
  23. Now let's finish entering the script.

     

    Enter the desired information into the Expression field. Enter

     a valid value
     e.g.
     "== 'Closed') {adf.error.raise(null)}"
    .

    Step 23
  24. We are done, so let's validate.

     

    Click the Validate button.

    Step 24
  25. We can safely dismiss this warning.

     

    Click the OK button.

    Step 25
  26. Now let's add the error message we want to display to users when they try to create the activity on a closed ticket.

    Click the Expand Error Message button.

    Step 26
  27. Enter the desired information into the Error Message field. Enter

     a valid value
     e.g.
     "You cannot create a new activity on a closed trouble ticket."
    .

    Step 27
  28. We are done.

     

    Click the Save and Close button.

    Step 28
  29.  In the next demo, we'll test the trigger.

    Step 29

  30. In this demo, you learned how to create a trigger for an object in Application Composer.

    You can find additional learning resources in your Oracle Fusion Help application, as well as in the Oracle Learning Library, and at Oracle University. Thank you.

    Step 30

Table of Contents  Start Topic