- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 03:33 AM
HI Community,
I have a requirement, in global level the variables of the ritm needs to be present in the request notifications.
This requirement is not specific to single catalog if request is raised from any catalog item then the variables of that catalog needs to be present in the notifications in sc_request (Request ) table.
Note : there is existing notification in request table in that i need to add the ritm variables
How can we achieve this?
Please explain in details as im new to mail script
Thanks in Advance
Suuriya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 05:17 AM
your notification is on sc_request table?
if yes then try this
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.addQuery('request', current.sys_id);
ritmRec.query();
if (ritmRec.next()) {
var vs = new GlobalServiceCatalogUtil().getVariablesForTask(ritmRec, true);
for (var i = 0; i < vs.length; i++) {
var isMRVS = lbl = vs[i].multi_row + "";
var lbl = vs[i].label + "";
var dis = vs[i].display_value + "";
var visible = vs[i].visible_summary + "";
if (isMRVS == 'true') {
var vArr = vs[i];
template.print("<div>" + "<strong>" + lbl + "</strong></div><hr>");
for (var j = 0; j < vArr.table_variable.length; j++) {
template.print("<div><strong>Row: </strong>" + (j + 1) + "</div>");
var tblArr = vArr.table_variable[j];
for (var k = 0; k < tblArr.length; k++) {
var mrvslbl = tblArr[k].label + "";
var mrvsdis = tblArr[k].display_value + "";
if (mrvslbl != '' && mrvsdis != '' && mrvsdis != 'false') {
template.print("<div>" + "<strong>" + mrvslbl + "</strong>" + ": " + mrvsdis + "</div>");
}
}
template.print("<hr>");
}
} else {
if (lbl != '' && dis != '' && dis != 'false' && visible == 'true') {
template.print("<div>" + "<strong>" + lbl + "</strong>" + ": " + dis + "</div>");
}
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 05:17 AM
your notification is on sc_request table?
if yes then try this
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.addQuery('request', current.sys_id);
ritmRec.query();
if (ritmRec.next()) {
var vs = new GlobalServiceCatalogUtil().getVariablesForTask(ritmRec, true);
for (var i = 0; i < vs.length; i++) {
var isMRVS = lbl = vs[i].multi_row + "";
var lbl = vs[i].label + "";
var dis = vs[i].display_value + "";
var visible = vs[i].visible_summary + "";
if (isMRVS == 'true') {
var vArr = vs[i];
template.print("<div>" + "<strong>" + lbl + "</strong></div><hr>");
for (var j = 0; j < vArr.table_variable.length; j++) {
template.print("<div><strong>Row: </strong>" + (j + 1) + "</div>");
var tblArr = vArr.table_variable[j];
for (var k = 0; k < tblArr.length; k++) {
var mrvslbl = tblArr[k].label + "";
var mrvsdis = tblArr[k].display_value + "";
if (mrvslbl != '' && mrvsdis != '' && mrvsdis != 'false') {
template.print("<div>" + "<strong>" + mrvslbl + "</strong>" + ": " + mrvsdis + "</div>");
}
}
template.print("<hr>");
}
} else {
if (lbl != '' && dis != '' && dis != 'false' && visible == 'true') {
template.print("<div>" + "<strong>" + lbl + "</strong>" + ": " + dis + "</div>");
}
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader