How to generate the GUID in script

Ketan Pandey
Tera Expert

How to generate the GUID in script 

4 REPLIES 4

Dipen Wadhwana
Giga Guru

Hi @Ketan Pandey , gs.generateGUID will always give you an unique key.

 

Please mark my answer helpful if it was helpful to you.

Pooja Mhaske
Mega Expert

Hi Ketan,

 

gs.generateGUID() will give you always a unique key.

 

Mark helpful or correct if applicable.

 

Regards,

Pooja.

RaghavSh
Kilo Patron

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

Vishal Birajdar
Giga Sage

Hi @Ketan Pandey 

 

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

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates