function for getting sys_id

kendall_lin
Giga Contributor

Hello,

Novice ServiceNow "developer" that would like to know what is the recommended practice for creating a global function that would get the sys_id of a specified record. We use scripts in our record producers to set values for various reference fields (business service, assignment group, etc.). Currently we are hardcoding the sys_id's and they vary by instance (DEV, UAT, PROD).

The most recent use case is when a user submits a Demand through a record producer. We would like to set the business service and assignment group for that Demand record. I know the name of the business service and assignment group, but do not know of a clean and simple method to get the sys_id based on that alone. I envision some type of function that would take some parameters (i.e. table, record name / label) and return the sys_id which I could then use to set current.business_service = 'returned sys_id'.

Any help would be appreciated.

Thanks,
Kendall Lin

15 REPLIES 15

palanikumar
Giga Sage

Hi,

In our environment we export table data as XML and import it into other environments if there is dependency with sys_id.

I understand from your message that you are not following this process. In this case create a script include and add function to get sys_id from the table using glide function. You can call this function from any of your script

 

Thank you,
Palani