GlidGuid in scoped application

Arun Chauhan
Giga Contributor

I am trying to generate a unique Cart Id in a application scoped Script on Fuji Instance.

var cartId = GlideGuid.generate(null);

But I am getting following error:

Evaluator: java.lang.SecurityException: GlideGuid is not allowed in scoped applications

  Caused by error in script at line 1

==> 1: var cartId = GlideGuid.generate(null);

The above line of code works well in global scoped script and I am able to generate a cart id.

How Can I access GlidGuid in application scoped sctipt?

1 ACCEPTED SOLUTION

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Arun,



You want to use gs.generateGUID():



gs.info(gs.generateGUID());



//output: x_snc_app: 87d2891f4fa0120087cdf9718110c7fb



Another alternative is to just create a new GlideRecord and get it's sys_id:



var myguid, anygr = new GlideRecord('incident');


anygr.initialize()



myguid = anygr.getUniqueValue();



Just don't save that GlideRecord.


View solution in original post

1 REPLY 1

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Arun,



You want to use gs.generateGUID():



gs.info(gs.generateGUID());



//output: x_snc_app: 87d2891f4fa0120087cdf9718110c7fb



Another alternative is to just create a new GlideRecord and get it's sys_id:



var myguid, anygr = new GlideRecord('incident');


anygr.initialize()



myguid = anygr.getUniqueValue();



Just don't save that GlideRecord.