Task assignment - Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 12:48 AM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 12:52 AM
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?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 12:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:35 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 01:58 AM
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