- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:29 AM
I have a requirement where I need to show the (RITM) item variable key, value on a notification page.
I looked into 2 tables, 'sc_req_item', 'sc_item_option_mtom'. I can filter required RITM and lookup the variable using fields "Dependent Item.Question.Display name", "Dependent Item.Question.Value" on UI. However, when I tried using basic script, I don't see variables returned.
==
var itemOption = new GlideRecord('sc_item_option_mtom');
itemOption.get('db3d44951b8e7550ac210fa5624bcb3c');
for (var key in itemOption ) {
gs.info('Attribute Name : '+key +' Value : '+itemOption[key]);
}
==
How do I query these values from my script (trying with background script).? I could be missing some basic thing.
Thanks for help!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:49 AM
@Sri29 :I just tried the same script in BG and below is the output for sample RITM.
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID('7f2fd6ed97c62110aa7c50081153aff4'); // RITM Sys ID
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
gs.log(vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue());
}
}
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:45 AM
@Sri29 : Here is the email script that can be used in notification to get the variable information.
function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.request_item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
template.print(vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue());
template.print("\n");
}
}
})(current, template, email, email_action, event);
I answered the similar question in another thread. Below is the link for your reference.
https://www.servicenow.com/community/virtual-agent-forum/adding-line-breaks-between-variables-in-ema...
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:49 AM
@Sri29 :I just tried the same script in BG and below is the output for sample RITM.
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID('7f2fd6ed97c62110aa7c50081153aff4'); // RITM Sys ID
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
gs.log(vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue());
}
}
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 11:31 AM
Hi,
Do you have multi row variable set as well?
You can go through the below article for getting all types of variables.
Thanks and Regards,
Saurabh Gupta