- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi all
I'm currently working on a requirement to allow Service Desk users to edit the variables on RITM records if needed (and, yes, we have tried to persuade the requestor that they should be cancelled and re-raised but losing that battle).
I have the config done for allowing the changes to happen but am struggling to find a way to write the new variable values to a comment on the RITM so the Requested For can be notified. I have tried both a business rule and flow, but can't seem to consistently bring back the variable question text plus old and new values.
I can see this information in the history of the RITM but just can't translate that into anything useable.
Has anyone tried this, or are there any suggestions of what to try?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can use before update business rule on RITM table
See which variable got changed and add the old and new value to work notes
check this link and sample script
How to add the work notes when catalogue variables are changed on RITM Form
OR
Sample script like this which worked for other where I shared solution
Updated work notes from the old value to the new value. -> you need to add which variables to track here
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var arr = [];
var variableArr = ['variable1', 'variable2', 'variable3'];
for (var i = 0; i < variableArr.length; i++) {
if (previous.variables[variableArr[i]] != current.variables[variableArr[i]]) {
gs.info('value changed for variable' + variableArr[i]);
arr.push('Variable changed from ' + previous.variables[variableArr[i]] + ' to ' + current.variables[variableArr[i]]);
}
}
current.work_notes = arr.join('\n');
})(current, previous);
OR
Before update BR on sc_req_item table and it will track any variable which got changed
Condition: current.cat_item.name == 'Your Item Name' && current.variables.changes()
Script:
(function executeRule(current, previous /*null when async*/ ) {
var question, prv1, cur1;
var cur = current.variables.getElements();
var pvr = previous.variables.getElements();
var arr = [];
for (var i = 0; i < cur.length; i++) {
if (cur[i] != pvr[i]) {
question = cur[i].getQuestion().getLabel();
cur1 = cur[i]; // current value
prv1 = pvr[i]; // previous value
var str = 'The ' + question + 'has changed from ' + prv1 + ' to ' + cur1;
arr.push(str + '\n');
}
}
current.work_notes = arr.toString();
})(current, previous);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can use before update business rule on RITM table
See which variable got changed and add the old and new value to work notes
check this link and sample script
How to add the work notes when catalogue variables are changed on RITM Form
OR
Sample script like this which worked for other where I shared solution
Updated work notes from the old value to the new value. -> you need to add which variables to track here
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var arr = [];
var variableArr = ['variable1', 'variable2', 'variable3'];
for (var i = 0; i < variableArr.length; i++) {
if (previous.variables[variableArr[i]] != current.variables[variableArr[i]]) {
gs.info('value changed for variable' + variableArr[i]);
arr.push('Variable changed from ' + previous.variables[variableArr[i]] + ' to ' + current.variables[variableArr[i]]);
}
}
current.work_notes = arr.join('\n');
})(current, previous);
OR
Before update BR on sc_req_item table and it will track any variable which got changed
Condition: current.cat_item.name == 'Your Item Name' && current.variables.changes()
Script:
(function executeRule(current, previous /*null when async*/ ) {
var question, prv1, cur1;
var cur = current.variables.getElements();
var pvr = previous.variables.getElements();
var arr = [];
for (var i = 0; i < cur.length; i++) {
if (cur[i] != pvr[i]) {
question = cur[i].getQuestion().getLabel();
cur1 = cur[i]; // current value
prv1 = pvr[i]; // previous value
var str = 'The ' + question + 'has changed from ' + prv1 + ' to ' + cur1;
arr.push(str + '\n');
}
}
current.work_notes = arr.toString();
})(current, previous);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
thanks Ankur
Is there a way to set the script to work on any catalogue item? I want this to work across all RITMs. Could the condition be changed on the second BR to be just 'current.variables.changes()'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
yes why not
I simply added that so that it runs only for RITMs belonging to particular catalog item
You can remove that and test once for 2/3 RITMs belonging to different catalog iem
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Amazing, thanks, that has worked!
I don't suppose you know why it appends a comma to the beginning of the lines in the comment?:
Is this a replacement for a lost or broken iPhone? has changed from no to yes
,Choose the colour has changed from graphite to silver
