How to compare previous and current worknotes and comments using flow designer

Priyadharashin1
Tera Contributor

Hi All,

 

I have a requirement to send a outbound PATCH request to a 3rd part when ant of the field is changed in Incident form.

When I change the worknotes, the PATCH request includes both the latest worknote and latest additional comment in the Payload , so I am trying to put a filter in the flow designer such that if worknotes is changed only it should be included in the payload and same for additional comment as well.

 

Please provide some suggestions.

13 REPLIES 13

@Priyadharashin1 

you can get to know which field got changed when record is updated

Use the Changed Fields step in flow

Using the data within the "Changed Fields" Pill 

Changed Fields of Flow Designer 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

I tried that. The Previous values always remains empty and current value shows all the worknotes entered so far. Pls see the rela time values below:

 

{
    "Changed Fields": [
        {
            "current_display_value": "18-04-2023 15:33:26 -Priyadharashini (Additional comments)\ntesting comments 2\n\n18-04-2023 15:21:15 - Priyadharashini (Additional comments)\ntesting comments 1\n\n18-04-2023 11:29:21 - Priyadharashini (Additional comments)\ntesting worknotes 2\n\n18-04-2023 09:34:13 - Priyadharashini Vijayaraghavan (Additional comments)\nTEsting worknotes\n\n",
            "current_value": "",
            "field_name": "comments",
            "previous_display_value": "",
            "previous_value": ""
        }
    ]
}

 

@Priyadharashin1 

that's because those are journal fields and data for it is stored in sys_journal_field table

you can query that table and get the latest value which will be the previous value for that record sysId and column

Sort it with Z to A for Created column

AnkurBawiskar_0-1681884189405.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

By your solution I have to store the latest value from the Journal entry somewhere, so once API is triggered, I can compare it. But, Where will I store the previous value before the flow is triggered?

 

@Priyadharashin1 

you can use flow variable which is like global variable or scratchpad variable

Flow variables 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader