Task assignment - Catalog item

Jai2021
Tera Contributor

Hi all, 
I have a rquirement that the generated task for a catalog item should be assigned to the respective assignment group based on the choice selection in the generic workflow.
I have chosen to rite script in the catalog mapping section of the catalog item. But it's not working as expected.could anyone help me.

Choices and it's values are  1.A - aa , 2. B -bb 3. C - cc

Assignment group A grp, B grp and C grp
My code:

var choice = current.variables.choices;

if(choice == 'A'){

task.assignment_group = 'sys_id of the group';}like for B and C as well.

Thanks! 

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Hi can you share the entire script?

usually the script should be on the activity where your creating task. Which activity are you using to create Task? 

Regards
Harish

Voona Rohila
Kilo Patron
Kilo Patron

Hi Abirami

are you mapping proper choice values? can you share screenshot of the variable.

use below logic in catalog task activity.

var choice = current.variables.choices.toString(); 
if(choice == 'A') // are you mapping proper choice value here?
task.assignment_group = 'sys_id of the group';
else if(choice == 'B')
task.assignment_group = 'sys_id of the group';
else
task.assignment_group = 'sys_id of the group';

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Thank you for the response guys!
The above script is not working unfortunately.
I found it work by the following script,
var choice = current.variables.var_name.getValue();

var grp = "";

if(choice == 'aa')//Value of the choice{
grp = 'sys id of group';

}

else if{

}

else{}

return grp;

You should map the choice values in if condition.

var choice = current.variables.choices.toString(); 
if(choice == 'aa') // are you mapping proper choice value here?
task.assignment_group = 'sys_id of the group';
else if(choice == 'bb')
task.assignment_group = 'sys_id of the group';
else if(choice == 'cc')
task.assignment_group = 'sys_id of the group';

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP