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 

Do you mean like this: 

  gs.eventQueue('lbg.notify.reassignBAS', current, previous.u_cmdb_data_steward.getDisplayValue(), current.u_cmdb_data_steward.getDisplayValue());
    

@matthew_hughes 

3rd parameter should be user sysId so it should be this

I hope you have marked Event parm1 contains recipient checkbox as True on notification

gs.eventQueue('lbg.notify.reassignBAS', current, previous.u_cmdb_data_steward, current.u_cmdb_data_steward.getDisplayValue());

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 that and it's not generating an event.

Hi @Ankur Bawiskar 

 

When it comes to my notification, how would I get the display name of the previous owner?

@matthew_hughes 

To whom email should be sent? the current user right present in that field?

are you saying you want to send email to the previous user?

If you wish to send to current user present in u_business_owner field then update as this

gs.eventQueue('lbg.notify.reassignBAS', current, current.u_cmdb_data_steward, previous.u_cmdb_data_steward.getDisplayValue());

Then in your email body wherever you wish to access the previous user use event.parm2 and not event.parm1 since we are sending it in 2nd parm

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