Can you use previous on a notification?

matthew_hughes
Kilo Sage

On a notification, I only want it to trigger if the following conditions are met:

if (previous.getValue('u_cmdb_data_steward.manager') == current.getValue('u_cmdb_data_steward')) {
    answer = true;
}
 
The above query checks if the previous manager of the steward is the current steward. Can you use previous in a notification?
22 REPLIES 22

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

As suggested by other using Event Queue + BR approach is the best for this use-case.

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

@Ankur Bawiskar I've tried the following, but it returns my current Sys ID:

 

 

matthew_hughes_1-1704729585642.png

 

matthew_hughes_2-1704729651695.png

matthew_hughes_3-1704729690142.png

 

matthew_hughes_4-1704729723236.png

 

How do I get the name of the previous user?

 

@matthew_hughes 

you should use this to get display value

previous.<fieldName>.getDisplayValue()

So 1 change is as below and you can make necessary changes at other places

previous.u_business_owner.getDisplayValue()

similarly apply it for other reference fields

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 Bawiskar  I've made the below changes to my code:

 

matthew_hughes_1-1704788383444.png

However, what I've found is that even if I make change to those 3 fields, it doesn't generate an event. Do you know why that could be?

@matthew_hughes 

3rd parameter should be recipient for eventQueue() method

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