- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 12:53 AM
How to get requested item variables and catalog name in rest api call.
I tried with current,variables.variable_name but its not working.
Also tried to dot walk requested item form and tried to query even its not working.
var state =1;
var grp="46cd5b6113fe7e003054b4622244b0cb";
//var cat = "36cf8d0d13363e003054b4622244b086";
var gr = new GlideRecord("sc_task");
gr.addQuery("state", state);
gr.addQuery("assignment_group", grp);
gr.addQuery("cat_item",cat); <This is not working>
so tried other way :
var state =1;
var gr = new GlideRecord("sc_req_item");
grCatItem.addQuery('name','=','SQL DatabaseProvision');
grCatItem.addQuery('active', true);
grCatItem.query();
grCatItem.next()
var grTask = new GlideRecord('sc_task');
grTask.addQuery("state", state);
grTask.addQuery("cat_item', grCatItem);
var c = grTask.request_item.variables.db_source;
so both the script is not working.
can someone help me. How to dot walk catalog item name in scripted rest api call. Also requested item variables.
In my task form we have catalog item name but if we try to get the via script its not working.
My Requirement is :
Try to get specific catalog item's task record from task form via scripted rest api get operation call.
someone knows how to query or dot walk the catalod name and the variables in scripted rest api. please share.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 02:27 AM
Hi Keerthi,
cat_item is not a field present on sc_task table.
request_item is a field which refers to RITM table which has cat_item field
If you want to query for catalog item then you can use following query which is updated one:
gr.addQuery("request_item.cat_item",cat); // cat is the sys_id of catalog item.
gr.query();
if(gr.next()){
var variable1 = gr.request_item.variables.variable1;
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
06-22-2017 06:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:56 AM
Great Keerthi,
Can you mark my answer as correct, helpful and hit like. This helps in removing this question from unanswered list and helps others to search similar question easily. Thanks in advance.
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
06-22-2017 02:33 AM
current.variables.<variable name>.getDisplayValue()
current.variable_pool.<variable name>.getDisplayValue()
Any of the above works.
There is a mistake in your Gliderecord variable , it should be 'gr' when you query.
Try below script:
var c;
var state =1;
var gr = new GlideRecord("sc_req_item");
gr .addQuery('name','=','SQL DatabaseProvision');
gr .addQuery('active', true);
gr .query();
while(grCatItem.next()){
c = gr .variables.db_source.getDisplayValue();
}
Also try c = gr .variable_pool.db_source.getDisplayValue();