How to convert GUID to UUID format?

Gowri S
Tera Expert

Hi All,

 

As one of our third-party systems needs us to pass UUID in the integration API call. Is the way to convert GUID to UUID format?

 

They are not accepting GUID format. Could you please help on it?

 

Thanks,

Gowri

 

 

1 ACCEPTED SOLUTION

Narsing1
Mega Sage

You may try like this.

var uuid = "18d874986a114520bd29466a446a50eb";
uuid = uuid.replace(/^([a-f0-9]{8})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{12})$/i, "$1-$2-$3-$4-$5");
gs.print(uuid);

Narsing1_0-1706032757012.png

 

Also, we have VMUtils OOTB functions to convert UUID to CorrelationID and vice-versa.  

VMUtils 

 

Thanks,

Narsing

View solution in original post

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, I would not expect a records unique identifier to be the same in both platforms\solutions and in your scenario would normally use an 'external identifier' field on the integrated table which would hold the vendors UUID. This field would then be mapped to sys_id during import/transform, meaning that it would be available to be passed to the vendor instead of the sys_id in any outbound payload.

Thanks Tony, but the third party system, expect us to generate uuid for each outbound api call from our system and sent in the payload, to identify unique transaction.

 

So it there method to generate uuid or convert guid for servicenow?

Narsing1
Mega Sage

You may try like this.

var uuid = "18d874986a114520bd29466a446a50eb";
uuid = uuid.replace(/^([a-f0-9]{8})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{12})$/i, "$1-$2-$3-$4-$5");
gs.print(uuid);

Narsing1_0-1706032757012.png

 

Also, we have VMUtils OOTB functions to convert UUID to CorrelationID and vice-versa.  

VMUtils 

 

Thanks,

Narsing

Gowri S
Tera Expert

Thanks Narsing, your solution helped 😊