Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Question on using setNewGuid() on scoped app

Naresh291
Tera Contributor

Hi ,

I have a workflow which will create a catalog task , so in the advanced section of the catalog task activity i have  scripted this way :

workflow.scratchpad.sys_id= task.setNewGuidValue();

Dont know why i am getting the sysid as undefined and workflow goes crazy post that.

If i use workflow.scratchpad.sys_id= task.setNewGuidValue(String value); 

it shows me an error in this particular line .

Can someone say how to use this in scoped app.

1 REPLY 1

Michael Jones -
Giga Sage

I've never had much success with setNewGuidValue() in a scoped app; seems like it is intended more to allow you to set an externally generated sys_id than it is to allow you to record the ID of a record. 

For catalog tasks, the only work-around I've come upon would be do something like this at the end of your catalog task script: 

workflow.scratchpad.sys_id = task.insert();

That creates the record and stores the sys_id as the script completes.

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!