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 01:09 PM
This is simple and works, but when I try to store the SYS_ID in a variable and use it in another GlideRecord area, it tells me the following:
'variable_name' is used out of scope
I don't really want to move everything in that while statement....how can I get the Sys_ID stored in a variable to use elsewhere?
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 01:12 PM
If you want to use it in the same script:
var choiceSysID= '';
var myObj = new GlideRecord('sys_choice');
myObj.addQuery('value','software');
myObj.query();
while(myObj.next()){
choiceSysID = myObj.sys_id;
}
However if you want to use it elsewhere in the system you might be able to use the scratchpad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 01:15 PM
Well now I feel dumb...should have known to declare the variable first.
Thanks!
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 01:17 PM
No problem, I still occasionally declare a variable inside a function and then wonder why the heck it's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 08:42 AM
Here is a creative way to use the Easy Import Template to export the sys_id data you are looking for.
Navigate to the list of records where you want to find the sys_id
Build your filter
Right click the header bar and select Import. Alternately you can also click the Hamburger > Import
Do you want to insert or update data? Update
Do you want to create an Excel template to enter data ? True
Include all fields in the template? True or False, your choice
Click Create Excel Template
Click Download
Open the Excel Spreadsheet
Select Page 1
In the far-right column, the sys_id is shown