Track MRVS variable changes and update RITM work notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- last edited
3 weeks ago
by
kh_safal
I have an MRVS where 3 variables are editable for a specific group when the RITM approval stage is “Requested”. I want to update the RITM work notes whenever any of these 3 variables are changed to track the updates.
What is the best way to log MRVS variable changes and update RITM work notes when these variables are modified?
Any suggestions or best practices would be helpful.
Regards,
Pooja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @pooja0910
May you use an After Update Business Rule on sc_multi_row_question_answer.
- Filter to your 3 MRVS variables
- Compare current.value vs previous.value
- Check RITM approval stage = Requested
- If changed, write a message to the parent RITM work notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can use before update BR on RITM and check the previous and current mrvs JSON string and then compare the JSON and see if any of those 3 variables within MRVS changed
if yes then update the work notes
Something like this
(function executeRule(current, previous) {
var MRVS = 'mrvsVariableSetName'; // <-- your MRVS variable name
var KEYS = ['user', 'subjects', 'incident']; // give name of the variables within MRVS which you need to check
var cur = parse((current.variables[MRVS] || '') + '');
var pre = parse((previous.variables[MRVS] || '') + '');
var diffs = [];
var len = Math.max(pre.length, cur.length);
for (var i = 0; i < len; i++) {
for (var k = 0; k < KEYS.length; k++) {
var key = KEYS[k];
var a = val(pre[i], key),
b = val(cur[i], key);
if (a !== b) diffs.push({
row: i + 1,
field: key,
from: a,
to: b
});
}
}
if (diffs.length) {
current.work_notes = 'your text';
}
function parse(s) {
try {
var x = JSON.parse(s || '[]');
return Array.isArray(x) ? x : [];
} catch (e) {
return [];
}
}
function val(row, key) {
return row && row[key] != null ? (row[key] + '').trim() : '';
}
})(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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader