- 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-17-2020 09:51 PM
can you make these 2 changes and try one
1) make this change
var notiBodyString = event.parm2.toString();
2) Also remove event parameter 2 contains recipient checkbox for your notification
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-19-2020 01:43 AM
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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-20-2020 01:12 PM
Hi Ankur,
apologizes for delay reply.
it is still not getting value,can you chek it in my PDI.
this functionality running in my PDI only.
Business Rule :
(function executeRule(current, previous /*null when async*/ ) {
var question, i, prv1, cur1;
var arr = [];
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]) {
var obj = {};
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);
obj["variableName"] = cur[i].getQuestion().getLabel();
obj["currentValue"] = cur[i].getQuestion().getDisplayValue();
obj["oldValue"] = pvr[i].getQuestion().getDisplayValue();
arr.push(obj);
}
}
gs.info('Entered');
gs.info("JSON:" + JSON.stringify(obj));
gs.info("Array:" + JSON.stringify(arr));
gs.eventQueue("updateventemail", current, gs.getUserID(),JSON.stringify(arr));
}
})(current, previous);
Email Script:
template.print("<b>Summary of items:\n</b>");
var notiBodyString = event.parm2.toString();
gs.info('notiBodyString :'+notiBodyString);
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 09:38 PM
Please share your pdi url and some admin credentials here ankurb.snow@gmail.com
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-20-2020 11:28 PM
Hi,
please remove event parameter 2 contains recipient checkbox for your notification
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader