Skip to main content
bisheswart9459
February 16, 2024
Question

compare 2 Rule inputs

  • February 16, 2024
  • 5 replies
  • 0 views

I have 2 rule inputs one is prevData and another is UpdatedData . I want a rule expression that will compare the two rule inputs and return the different fields and values from prevData rule input . And the I need to add the fields and values to another rule input which will be a input for write record smart service . Can anyone help me with proper steps ,please !

    5 replies

    stefanhelzle0001
    Brainy
    February 16, 2024

    The most simply approach is to just compare field by field while creating the output.

    'recordType!AA Category'(
      field1: ri!data1.field1 = ri!data2.field1,
      .
      .
      .
      .
    )

    harshitb6843
    February 16, 2024

    Do you just need to compare if they are same or not? That can be done using a simple equals operator. But if you need specific fields that got changed, you can use a!keys() function, run a loop on the keys and compare the property's value from prevData with UpdatedData, and add it to a map.

    bisheswart9459
    February 16, 2024

    I need both the fields and the values those are got changed in updatedData.

    harshitb6843
    February 16, 2024

    Yep. Like I said, you can run a loop by all the fields of the RI using a!keys() function and passing it in a!forEach()