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

Allen Andreas
Administrator
Administrator

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:



find_real_file.png



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!

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

Community Alums
Not applicable

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);


      }



}


Liju John1
Mega Guru

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);


}