- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 01:46 PM
Hi,
some one suggest me about this use case how to solve
I created a notification, just update it a bit as below
but that notification has to carry only modified variables details only with Old value , new value of variable when we change variable value in RITM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2020 01:08 AM
please update as below and try once
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
template.print("<b>Summary of items:\n</b>");
var notiBodyString = event.parm2;
var parsedData = JSON.parse(notiBodyString);
template.print('<br>');
gs.info("parsedData" + parsedData);
template.print('parsedData----------' + parsedData + '\n' + '\n');
var notiLength = parsedData.length;
template.print('<br>');
gs.info('notiLength' + notiLength);
template.print('notiLength----------' + notiLength);
for(var i=0;i<parsedData.length;i++){
template.print('Variable ' + parsedData[i].variableName + ' old value ' + parsedData[i].oldValue + ' new value ' + parsedData[i].currentValue);
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 02:31 PM
Hi,
I have a few suggestions that might get you started.
First of all, whenever you deal with email scripts and record queries, it is safe to assume that you will require server side scripting. As such, the new/old value parameters seen on onChange() client scripts just wont work.
What you should consider instead is using the "previous" specifier seen on business rules. See the post below to learn more about current vs previous:
https://community.servicenow.com/community?id=community_question&sys_id=635d9dc9dbf94c106064eeb5ca96197b
That being said, previous is not accessible from email scripts. You will need to set up an event trigger and pass the previous values to param1 / param2. Since emails are triggered by events, you may call the parameter values from there. Please refer to the below article:
https://community.servicenow.com/community?id=community_question&sys_id=e6b383a5dbd8dbc01dcaf3231f96196f

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 09:20 PM
Hello Sironi,
Some one here,
Please try the below URL,I am also working on this solution to implement it on my instance.
Also check the below link.
Regards
Yash Agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2020 01:32 AM
Hello
I tried very hard to get a solution,
Please follow the below steps:
1.Create an event.
2.Create a business rule with the same name, which you gave to Event.
Write the below code there.
(function executeRule(current, previous /*null when async*/ ) {
var question,i,prv1,cur1;
if (current.variables.changes())
{
var cur = current.variables.getElements();
var pvr= previous.variables.getElements();
gs.info('Current Value-' + current.variables.getElements());
gs.info('Previous Value-' + previous.variables.getElements());
for (i = 0;i<cur.length;i++)
{
if(cur[i] != pvr[i])
{
question = cur[i].getQuestion().getLabel();
gs.info('question'+question);
cur1=cur[i];
gs.info('current value'+cur1);
prv1=pvr[i];
gs.info('prvious value'+prv1);
}
//gs.eventQueue('updateevent',current,question,'Cuurent Value-'+cur1+',Previous Value-'+prv1);
}
}
})(current, previous);
4.To check,
Open any RITM, change the value of any 1 variable (for testing purpose)
Go to logs.
You will see the record which contains
Question: Name of the variable
Current Value: Current Value
Previous value: Previous value that you modified.
If and Only if the value if modified/updated.
Please check the below scrrenshot
I am working on how to send this value in Notification,I will do that also,but need some time.till that time you can try to implement the provided solution.
Regards
Yash agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 03:11 AM
Hello Sironi,
Did you check the logs from above screenshot?
You can see we are getting current value and previous value if and only if it is changed.
Please implement this solution till here,and check you are getting the same result or not.
If is giving you correct value ,then we can create notification to send the variable detials to the user.
I already implemented the solution on my instance
Regards
Yash Agrawal