Based on list collector values , create catalog task in workflow

vinzz
Kilo Contributor

Hi,

 

I have a catalog item, which contains a list collector that reference to assignment groups of servicenow.

Requirement is to create catalog task for all the assignment groups selected in list collector.

Please advice.

 

Thanks in advance

15 REPLIES 15

Did you try with the solutions provided by others? 

And also try with current.variable_pool.list_collector

vinothkumar
Tera Guru
Try the below code in the run script activity var group = current.variables.list_collector; var groups = group.split(","); Var m = new GlideRecord ("sc_task"); m.initialize(); for(var i=0;i

vinzz
Kilo Contributor

HI All,

 

Thanks for prompt reply.

I have configured the-

 

 var group = current.variables_pool.u_group.getDisplayValue();

var groups = group.split(",");
gs.log(group);
gs.log(groups);


var m = new GlideRecord("sc_task");
m.initialize();

for(var i=0;i<groups.length; i++){


task.assignment_group = groups[i];
task.insert();


}

 

The number tasks are generated correctly, but the assignment group is blank for all task.

Not sure if I am missing something.

This I have configured in activity of workflow.

Hello,

Try with the below code

var m = new GlideRecord("sc_task");
m.initialize();

for(var i=0;i<groups.length; i++){


m.assignment_group = groups[i];
m.insert();

Vinay Mishra3
Mega Guru

Hi,

Try the below code

 var group = current.variables_pool.u_group.getDisplayValue();

var groups = group.split(",");
gs.log(group);
gs.log(groups);


var m = new GlideRecord("sc_task");
m.initialize();

for(var i=0;i<groups.length; i++){


task.assignment_group.setDisplayValue(groups[i]);// You have stored name of the groups in group variable so you need to use setDisplayValue.


task.insert();


}

Please make correct/helpful, if it's applicable.

Thanks,

Vinay