- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 08:02 AM
Hi,
I am having scoped application. On RITM, we have catalog item with variables.
Following code perfectly works in global scope but on local scope getGlideObject is not allowed.
Please suggest alternative.
var ritmRecord = new GlideRecordSecure('sc_req_item');
ritmRecord.addQuery('request', <req_sys_id>);
ritmRecord.query();
while (ritmRecord.next()) {
var value = ritmRecord.variables["tracking_id"].getGlideObject().getValue();
}
Thanks
Ajit
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 08:09 AM
Hi Ajit,
I have used this for global and scope
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', 'e5317f3b07f401102011ff208c1ed063');
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != '' && value != ''){
gs.info(' ' + label + " = " + value + "<br/>");
}
}
Output:
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
01-12-2022 08:09 AM
Hi Ajit,
I have used this for global and scope
var ritm = new GlideRecord('sc_req_item');
ritm.get('request', 'e5317f3b07f401102011ff208c1ed063');
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != '' && value != ''){
gs.info(' ' + label + " = " + value + "<br/>");
}
}
Output:
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
01-12-2022 11:19 PM
Thanks Ankur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 11:49 PM
Hi @Ankur Bawiskar ,
On this line, I am getting exception
var question = variables[j].getQuestion();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 12:02 AM
Hi,
are you having MRVS in your item?
possibly that might be giving you the issue. The script I shared needs to be tweaked for MRVS
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader