Set assignment group based on variable

nikhitha24
Tera Guru

I have a service Request that I would like to have auto-assigned based on a value from one of the variables. The variable is a select box in the question choice i need to be auto assigned based on this how can we achieve this through workflow.

The below screenshot is referred to the variable question choices.

 

nikhitha24_0-1705502543810.png

I have written this in the workflow but it is not working.

 

nikhitha24_1-1705502590352.png

 

 

 

This are the assignment groups i need when i select the assignment group.

 

  • E&G   à Hosting - Backup - IT         
  • MinAu IT  à Hosting - Backup - MinAu - IT
  • MinAu OT  à Hosting - Backup - MinAu - OT
  • MinAm IT  à Hosting - Backup - MinAm – IT
1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

Hello @nikhitha24 ,

You can give a try to the script below and let me know how it works for you.

// Get the assignment groups sys_ids from the property
var assignmentGroupIds = gs.getProperty('assignment_groups_ids');

// Get the value of the variable (replace 'your_variable_name' with the actual variable name)
var selectedValue = current.variables.your_variable_name;

// Set the assignment group based on the variable value
if (selectedValue == 'E&G value') {
    current.assignment_group = assignmentGroupIds[0];
} else if (selectedValue == 'MinAu IT value') {
    current.assignment_group = assignmentGroupIds[1];
} else if (selectedValue == 'MinAu OT value') {
    current.assignment_group = assignmentGroupIds[2];
} else if (selectedValue == 'MinAm IT value') {
    current.assignment_group = assignmentGroupIds[3];
}
// Add more else if branches as needed for other values

// Update the record
current.update();

// Note: 'current' refers to the RITM, adjust accordingly if working with Catalog Task
// If needed, set the Task assignment group separately using 'task.assignment_group'

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post

3 REPLIES 3

Adrian Ubeda
Mega Sage
Mega Sage

Hello nikhitha24, 

You should add 'if' statement inside your run script action for select each assignment group based on decision, apart from that I'll create a property and store there all sys_ids from assignment group, in case you need to add additional group in future you'll need to change property only; should be something similar as follows:

//if you want to test before create the entire solution

if(current.variables.asset_field == 'E&G value') {
  current.assignment_group = 'sys_id_Hosting - Backup - IT';
  current.update();
}

//This is the entire solution using property

var assignmentGroup = gs.getProperty('assignment_groups_ids');
if(current.variables.asset_field == 'E&G value'){
  current.assignment_group = assignmentGroup[0];
}else if(current.variables.asset_field == 'MinAu IT value'){
  current.assignment_group = assignmentGroup[1];
}
//add else if branches as need it
...
current.update();
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Brad Bowman
Kilo Patron
Kilo Patron

In addition to excellent suggestions by @Adrian Ubeda, keep in mind that 'current' refers to the RITM, while in the Catalog Task activity 'task.assignment_group' will set the assignment group of that Catalog Task, so use the appropriate method.  Setting the Task AG could then set the AG of the RITM if you have a Business Rule in place to update the RITM AG when a Catalog Task AG changes.  Also, you shouldn't ever need to use current.update() in any workflow script. 

Aniket Chavan
Tera Sage
Tera Sage

Hello @nikhitha24 ,

You can give a try to the script below and let me know how it works for you.

// Get the assignment groups sys_ids from the property
var assignmentGroupIds = gs.getProperty('assignment_groups_ids');

// Get the value of the variable (replace 'your_variable_name' with the actual variable name)
var selectedValue = current.variables.your_variable_name;

// Set the assignment group based on the variable value
if (selectedValue == 'E&G value') {
    current.assignment_group = assignmentGroupIds[0];
} else if (selectedValue == 'MinAu IT value') {
    current.assignment_group = assignmentGroupIds[1];
} else if (selectedValue == 'MinAu OT value') {
    current.assignment_group = assignmentGroupIds[2];
} else if (selectedValue == 'MinAm IT value') {
    current.assignment_group = assignmentGroupIds[3];
}
// Add more else if branches as needed for other values

// Update the record
current.update();

// Note: 'current' refers to the RITM, adjust accordingly if working with Catalog Task
// If needed, set the Task assignment group separately using 'task.assignment_group'

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket