WorkflowCatalog Task: dynamic assignment group based on variable choices

thomasnoret
Kilo Contributor

Hi guys,

I'd like to send a catalog task to a dynamic assignment group based on choices made by the user a the catalog task ?

What script should I use ?

Example :

Variable "TEST : A or B or C

Groups Group_A or Group_B or Group_C

if variable chosen by user on catalog item is A then use assignment group "Group_A"   if B then "Group_B" etc...

I had something like that for retrieving the country of the requester and then assign it to a specific group.

var CountryFR = '3117032fe58a6000fd3edfe8fab4b7b9'; // Country FR SysID

var GroupNameFR   = 'f6bd6ebf7c33400052b08846ae1c9cb9'; // Group FR SysID

if (current.u_requested_for.location.u_country == CountryFR) {

task.assignment_group = GroupNameFR;

}

else i can sure have as many catalog tasks as i have variables but it would be easuer by a script as i have 10 of them at least for now...

I dont know how to code it but it would be something like this ? or maybe another way is simplier ?

var VariableA = '3117032fe58a6000fd3edfe8fab4b7b9'; // Variable A SysID

var GroupA   = 'f6bd6ebf7c33400052b08846ae1c9cb9'; // Group A SysID

if (Variable choosen == VariableA) {

task.assignment_group = Group_A;

}

Thanks a lot for the help !

1 ACCEPTED SOLUTION

Nate23
Mega Guru

if we knew whether there was any relation to the variables and the groups that would help make it a little more dynamic for future enhancments lets say you have variable D and group D added in the future, but if there isnt than hard coding it the way you explained above would be the only way...



basically your code would look something like this:



var group;


var myVar = current.variables.var_name_here;



if(myVar == 'a'){


group='sys_id of group a';


}else if(myVar == 'b'){


group='sys_id of group b';


}


else if(myVar == 'c'){


group='sys_id of group c';


}



task.assignment_group = group;


View solution in original post

3 REPLIES 3

Nate23
Mega Guru

if we knew whether there was any relation to the variables and the groups that would help make it a little more dynamic for future enhancments lets say you have variable D and group D added in the future, but if there isnt than hard coding it the way you explained above would be the only way...



basically your code would look something like this:



var group;


var myVar = current.variables.var_name_here;



if(myVar == 'a'){


group='sys_id of group a';


}else if(myVar == 'b'){


group='sys_id of group b';


}


else if(myVar == 'c'){


group='sys_id of group c';


}



task.assignment_group = group;


many thanks it works...



unfortunately i don't always know if A => Group A ... so in the script manually it's great thanks   !


This worked great can you tell me how to "code once use many" for this? I have to assign tasks dynamically using a Business Application selection dropdown on multiple catalog items and would like to call the script rather then have to manage seperately on every catalog item it touches. Can I assume script includes? the variable name is agency_mgmt and I would pass that from the form to the script.