- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2021 10:38 PM
how will you generate a new sys_id by scripting in servicenow?
and What are the different ways to do so?
Solved! Go to Solution.
- Labels:
-
flow designer
-
Service Portal
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2021 11:09 PM
In addition to Ankur's newRecord() function, you can also use the below code(Used in server side) :
gs.generateGUID()
To get the sys id of a record that is about to be created on the client side, you can use:
g_form.getUniqueValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2021 10:48 PM
Hi,
you can use newRecord() method to generate sys_id from script
Remember unless you insert the record it won't be available in the table
var rec = new GlideRecord('incident');
rec.newRecord();
gs.info(rec.sys_id);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2021 06:59 AM
I could see you marked my response as correct earlier but now it is not.
You can mark only 1 response as correct.
Please mark appropriate response as correct and helpful so that it benefits other members.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2021 11:09 PM
In addition to Ankur's newRecord() function, you can also use the below code(Used in server side) :
gs.generateGUID()
To get the sys id of a record that is about to be created on the client side, you can use:
g_form.getUniqueValue();