How to generate the GUID in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-08-2023 11:11 PM
How to generate the GUID in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-08-2023 11:20 PM
Hi @Ketan Pandey , gs.generateGUID will always give you an unique key.
Please mark my answer helpful if it was helpful to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-08-2023 11:22 PM - edited â10-08-2023 11:22 PM
Hi Ketan,
gs.generateGUID() will give you always a unique key.
Mark helpful or correct if applicable.
Regards,
Pooja.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-08-2023 11:26 PM
gs.generateGUID(); will generate unique GUID, but it will only work in server side script.
If you want this in client side, you need to call this is script include through glideAjax
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-08-2023 11:33 PM
If you want to set new Guid while creating record through GlideRecord then use:
gr.setNewGuidValue(); //Sets sys_id value for the current record
If you want to generate GUID then using GlideSystem then use :
gs.generateGUID(); //Generates a GUID that can be used when a unique identifier is required
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates