How to get sysid of added items to Order Guide using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 07:43 AM
Hi guys
Would anyone know how I could get the sysid of items added to an Order Guide using script? I have an Order Guide for New Hires which auto selects items for a new joiner depending on role.
If a new joiner for example has a role of Operator, the items, Slack, ServiceNow, Confluence access etc. will be added to the Order Guide. I need to be able to auto populate the level of Access for these applications (catalog item level)
i.e.
In Order Guide, I have a variable called Level of Access for Slack (slack_level_of_access)
In Slack Catalog item, I will populate the variable slack_level_of_access with whatever value I have set in Order Guide variable. (both variables have same name to be able to cascade value to catalog item)
Right now this is working but with hard-coded values (for demo purposes)
Basically, I would like to be able to loop through all the items in Order Guide, lookup the level of access table and use the catalog item sysid as key, then populate the variables to be cascaded to the catalog items.
I couldn't find a way to do this from here or SNow documentation.
Any help is greatly appreciated.
Thanks
Regina
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 07:56 AM
Hi,
Which version are you on? If you are on Kingston then you can use new order guide widget?
or are you doing something that cascade variable doesn't provide?
I can help you code it once i know which widget are you using kingston or pre-kingston?
Mark my ANSWER as CORRECT / HELPFUL if it served your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 12:35 AM
Hi Bhagyashree, thanks for the reply.
I am hoping to do the following in a client script:
1. Loop through all the sysids of catalog items added to the order guided
2. Pass each sysid to a function that gets the value of level of access from the M2M u_m2m_technical_se_job_roles to get level of access value.
i.e.
var job_role = g_form.getValue('u_job_role');
var sysids = array of sysids of catalog items // I wanted to know how to do this
var levofaccess;
for (i = 0; i < sysids.length; i++) {
levofaccess = getLevelofAccess(job_role,sysids[i]);
if(sysid[i]=='sysidofSlack'){
g_form.setValue('slack_level_of_access', levofaccess );
else if(sysid[i]== 'ServiceNow'){
g_form.setValue('snow_level_of_access', levofaccess );
} etc etc
}
function getLevelofAccess(job_role,catItemsysID){
var levAccess = '';
var gr = new GlideRecord('u_m2m_technical_se_job_roles');
gr.addEncodedQuery('u_job_roles='+job_role+'^u_technical_service=' +catItemsysID );
gr.query();
if(gr.hasNext()){
return gr.level_of_acccess;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 03:17 AM
and what kind of client script is this? Widget client script or client script on order guide? like onChange on a field or something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 03:24 AM
Hi Bhagyashree, It's an onChange catalog client script for Job Role variable. So when job role is populated / changed, then the code will trigger.
Thanks
Regina