- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 09:26 AM
I have a requirement to send a notification. in this notification will be alot of information so im building a email script for one part of this notification.
requirement - If "Description" changes i want to see what it was prior and after the change.
so i built a email script to put in the notification but its not working as i think it should. can someone assist
(function runMailScript ( /* GlideRecord */ current, previous, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {
if (previous.description != current.description ) {
template.print ( "CTASK Description was changed from: " + previous.description);
template.print ( "CTASK description was changed to: " + current.description);
}
})(current, previous, template, email, email_action, event);
I would like to keep this as a script can someone see what i'm missing or doing wrong to get the data I desire.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 10:10 AM
Hi @Walter Toney ,
In email Script, did you modify the function to get previous value ? because I don't see if you can use previous value like that. ServiceNow can be used like:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 09:32 AM
I dont think previous is accessible in email script.
If you want to send current and previous, you need to create an onAfter Business Rule.
In the onAfter Business Rule, trigger an event and pass the old description as one of the event parameters.
The event should be linked to a notification.
Then you can access that parameter in the notification itself. You will not have to create a email script also.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 09:40 AM - edited 01-17-2024 09:41 AM
Hi @Walter Toney
The object "previous" is not available in mail scripts.
You need to write a onAfter BR and fire an event with old and new description to have in the notification.
You can refer the below post to achieve the same.
Solved: How to get previous value in Email Notification? - ServiceNow Community
C |
If the provided solution meets your needs, kindly consider marking it as helpful and accepting it as the solution. This helps others who may have similar questions. |
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 10:10 AM
Hi @Walter Toney ,
In email Script, did you modify the function to get previous value ? because I don't see if you can use previous value like that. ServiceNow can be used like: