The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Get sys_id of a string field on an Incident

Steven Parker
Giga Sage

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
9 REPLIES 9

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

Community Alums
Not applicable

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.


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

Community Alums
Not applicable

No problem, I still occasionally declare a variable inside a function and then wonder why the heck it's not working


Bipul Vishwakar
Tera Contributor

 

Here is a creative way to use the Easy Import Template to export the sys_id data you are looking for.

  1. Navigate to the list of records where you want to find the sys_id

  2. Build your filter

  3. 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

  4. Click Create Excel Template

  5. Click Download

  6. Open the Excel Spreadsheet

  7. Select Page 1

  8. In the far-right column, the sys_id is shown