function for getting sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 08:59 AM
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
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 06:16 AM
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
Palani