The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to get previous value on email script

mania
Tera Contributor

Hi,

 

I have a scenario The email subject should be updated to indicate that the incident number has been escalated to the respective group, specifically when the ticket is moved from A to B group. 

So how to take previous in email script?

Can anyone please help on this, it will be helpful/

 

Thanks! 

2 REPLIES 2

Bhuvan
Kilo Patron

@mania 

 

Refer below articles on how to get previous values in email script

 

https://www.servicenow.com/community/developer-forum/how-to-get-previous-value-in-email-notification...

 

https://www.servicenow.com/community/service-operations-workspace/print-updated-fields-in-email-noti...

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

Ankur Bawiskar
Tera Patron
Tera Patron

@mania

email script only has access to current object and not previous. 

you can't access previous value in email script if you didn't call the email notification via gs.eventQueue() method

you can use after insert/update BR and use gs.eventQueue() approach and send the previous value

Then use that in email script

Example:

BR -> I am sending previous assigned to name in parm2

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	gs.eventQueue('eventName', current, current.assigned_to, previous.assigned_to.name.toString());

})(current, previous);

Then in email script use this event.parm2 to get that value

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here

	template.print('Previous Assigned to user is: ' + event.parm2);

})(current, template, email, email_action, event);

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