Get sys_id of a string field on an Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:29 PM
I am working on a UI action and I need to get the SYS_ID of the category/subcategory selected on an Incident. Those fields are string fields, so how can I obtain the sys_id of the choices in each drop down? So if the Incident category is "Software" and the value is "software"....how can I obtain the sys_id of "software"? I tried some various things, but since it isn't a reference field on the Incident I am struggling to get the answer here. I have Client checked in the UI Action (because I am using a confirmation box before executing the UI Action), but functions, callbacks, dot walking...nothing seems to work.
I need to use that SYS_ID in another reference field for something we are doing.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:43 PM
You should be able to navigate to that exact choice and then in the gray header, right click and choose copy sys_id like so:
So essentially the dictionary entry for it and right click and there ya go
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:46 PM
I know how to obtain it by right clicking in the header. I hard coded it in my UI Action script to know it works with the sys_id in there, but I need to obtain it programmatically. The fact that it is a string field is what is throwing me off.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:53 PM
Here is how you could do it wish a nested glide record if you need it scripted:
var grIncident = new GlideRecord('incident');
grIncident.addQuery('sys_id','enter SYS_ID of incident here');
grIncident.query();
while (grIncident.next()) {
gs.print('Value of category on incident: ' + grIncident.category);
var grChoice = new GlideRecord('sys_choice');
grChoice.addQuery('name','incident');
grChoice.addQuery('element','category');
grChoice.addQuery('value',grIncident.category);
grChoice.query();
while (grChoice.next()) {
gs.print('Category Label: ' + grChoice.label);
gs.print('Category SysID: ' + grChoice.sys_id);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:57 PM
you could find it from sys_choice table
var myObj = new GlideRecord('sys_choice');
myObj.addQuery('value','software');
myObj.query();
while(myObj.next()){
gs.log("SW SYS_ID"+myObj.sys_id);
}