How to get RITM variables display value using REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 09:33 PM
Hi All,
How to get RITM variables display value using REST API with out using scripted REST API.
Can someone help on this.
Thanks,
Rajashekhar Mushke
- Labels:
-
Instance Configuration
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 09:44 PM
Hi,
Below blog will help you to achieve this
Please mark my answer correct and helpful.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 09:57 PM
create one script include and there you will use getDisplayValue() while fetching the variable value.
now in your scripted rest api use that script include.
sample code for getting all ritm variables. make the changes based on your need.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while (gr.next()) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(gr.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.print("\n"+ '<b>' +vs.get(i).getLabel() + " = " + '</b>' + vs.get(i).getDisplayValue() + "\n");
}
}
blog for further details to use script include inside the scripted rest api.
https://www.servicenowtechminds.com/single-blog.php?id=23
If my answer helped you, kindly mark it as correct and helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 10:13 PM
Hi Rajashekhar,
Do you require scripted REST API?
Because this is possible using OOB table API as well.
Regards
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 03:01 AM