How to get previous value on email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Refer below articles on how to get previous values in email script
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader