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.

Need help on getting the sys id of the catalog task in workflow

shaik_irfan
Tera Guru

 

Hi,

 

On the workflow i have a catalog task i need to get the sysID and the assignment group, can anyone please help me how to get this

 

find_real_file.png

 

Above is my workflow, i tried with below scrip in the catalog task activity but it is giving me the null value

 

// For example:
// task.short_description = current.short_description;

workflow.scratchpad.acbcd = task.sys_id + "Testing";

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

In the initial task you can use the following to save the sys_id

workflow.scratchpad.taskid = task.setNewGuid();

You can then use the following to retrieve any information about that task in the future.

var taskGR = new GlideRecord('sc_task');
if(taskGR.get(workflow.scratchpad.taskid)){

var group = taskGR.getValue('assignment_group');

}

 

Or use flow designer and make life 10x easier!

View solution in original post

3 REPLIES 3

Kieran Anson
Kilo Patron

Hi,

In the initial task you can use the following to save the sys_id

workflow.scratchpad.taskid = task.setNewGuid();

You can then use the following to retrieve any information about that task in the future.

var taskGR = new GlideRecord('sc_task');
if(taskGR.get(workflow.scratchpad.taskid)){

var group = taskGR.getValue('assignment_group');

}

 

Or use flow designer and make life 10x easier!

Thank You @Kieran Anson 

 

I never thought we can create a sys id from the catalog task activity. I agree to use flow designer but unfortunately its a old legacy workflow so updating the workflow

Harsh Vardhan
Giga Patron

If above script does not work, try with below script

 

Eg:

Use below script in catalog task activity 

 

var id = gs.generateGUID();
task.setNewGuidValue(id);
workflow.scratchpad.myCustID = id; 

 

Then use log in run script activity. 

 

gs.log('Value is '+workflow.scratchpad.myCustID);