Quality

Get Involved. Join the Conversation.

Topic

    Shylaja Shetty
    21: Application Composer: how to get the old and the new...Answered
    Topic posted March 7, 2019 by Shylaja ShettyGreen Ribbon: 100+ Points 
    162 Views, 6 Comments
    Title:
    21: Application Composer: how to get the old and the new field value inside a Server Script Trigger
    Content:

    My scope is to set the Description field value of a Quality Issue

     - with "Issue Name was just updated" value when the Quality Issue Name was just manually changed
     - or with "Issue Name was updated in the past" value when the Quality Issue Name still the same (during a Quality Issue update)

    To do it, I went to Application Composer -> application “ERP and SCM Cloud” -> Standard Objects -> Quality Issue -> Server Scripts -> Triggers -> Object Triggers > Add a New Trigger:
    Trigger: BeforeUpdate
    Trigger Name: BeforeUpdate_Description

    In Trigger Definition I have to check if the old value of Quality Issue Name is different from the new value of Quality Issue Name. Is it a way to do it?
    (for example in Oracle EBS there is the "before update" db trigger, and I can use "new.Name" and "old.Name" to get the old and the new value of a field)

     

    Best Comment

    Andre Guldi

    This is how it works; you can get the oldValue in an attribute trigger, but not object trigger, see here:

    https://docs.oracle.com/en/cloud/saas/engagement/19a/cgsac/groovy-tips-and-techniques.html#to_referencing_original_values_of_changed_fields

    Comment

     

    • Shylaja Shetty

      Hello Team,

       

      Can we have an update on this.

       

      Regards,

      Shylaja

    • Andre Guldi

      Using an object level pre-update trigger does not get you the old value, it only gets the new value.

      You can create a field validation rule, which provides both. oldValue and newValue are keywords there.
      From there you can call another function e.g.

      if (oldValue != newValue)
        doSomething(oldValue, newValue);
      println ("old : "+oldValue+" new : "+newValue);
      return true;

       

    • Shylaja Shetty

      Hello Andre,

       

       

      Thankyou for the update.

      thank you, now we'll try to use oldValue and newValue and I'll let you know

      where can I insert/write doSomething function/procedure?

       

       

      Regards,

      Shylaja

      • Andre Guldi

        Hi Shylaja

        doSomething could be an Object Function. Go to Apps Composer -> Standard Objects -> Quality Issue -> Server Scripts -> Object Functions.

        oldValue and newValue could be parameters (of that Function) of type String.

        Regards
        André

         

    • Shylaja Shetty

      Thankyou.


      The fact we can't get oldValue in pre-update trigger is wanted or is it a bug?
      Is there a way to get oldValue and newValue in pre-update trigger (without using field validation rules)?
      Is possible to get oldValue and newValue in other Application Composer functionalities (for example triggers, functions, ...)?

      • Andre Guldi

        This is how it works; you can get the oldValue in an attribute trigger, but not object trigger, see here:

        https://docs.oracle.com/en/cloud/saas/engagement/19a/cgsac/groovy-tips-and-techniques.html#to_referencing_original_values_of_changed_fields