How to set Assignment group for RITM?

Bhagya
Tera Contributor

I have a catalog item "ABC",

Which have a field called "System" with drop down values 'x', 'y', 'z'.

If I select "System" value as 'x' then the RITM assignment group should be 'x_group'

If I select "System" value as 'y' then the RITM assignment group should be 'y_group'

If I select "System" value as 'z' then the RITM assignment group should be 'z_group'

Could you please give the script for the above to add in workflow. also please provide a sample screenshot where to add the script in workflow.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Bhagya 

Hard-coding sysIds is not recommended.

Steps

1) Create 3 system property of type string and each will hold the group sysId for x, y and z

2) now you can use workflow run script if your catalog item has workflow linked with it OR you can use before insert business rule

Script would look something like this

Ensure you compare correct choice values for that drop down variable

var variableValue = current.variables.variableName; // please give your variable name here

if(variableValue == "x")
{
	current.setValue('assignment_group', gs.getProperty('groupXSysId'));
}
else if(variableValue == "y")
{
	current.setValue('assignment_group', gs.getProperty('groupYSysId'));
}
else if(variableValue == "z")
{
	current.setValue('assignment_group', gs.getProperty('groupZSysId'));
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

suvro
Mega Sage
Mega Sage

in run script activity you can use below

 

switch(current.variables.system){

case 'x': current.assignment_group = "sys_id_of_x_group";

 break;

case 'y' : current.assignment_group = "sys_id_of_y_group";

break;

case 'z' : current.assignment_group = "sys_id_of_z_group";

};

Mohith Devatte
Tera Sage
Tera Sage

Hello,

You can use Run script activity for this as below 

find_real_file.png

Use this kind of script in run script

if(current.variables.Systemfieldbackendname=="x")
	{
		current.assignment_group ="group record sysid";
	}
else if(current.variables.Systemfieldbackendname=="y")
		{
		current.assignment_group ="group record sysid";
		}
else if(current.variables.Systemfieldbackendname=="z")
		{
		current.assignment_group ="group record sysid";
		}

Please mark my answer correct if it helps you

 

Thank you, it worked.

Ankur Bawiskar
Tera Patron
Tera Patron

@Bhagya 

Hard-coding sysIds is not recommended.

Steps

1) Create 3 system property of type string and each will hold the group sysId for x, y and z

2) now you can use workflow run script if your catalog item has workflow linked with it OR you can use before insert business rule

Script would look something like this

Ensure you compare correct choice values for that drop down variable

var variableValue = current.variables.variableName; // please give your variable name here

if(variableValue == "x")
{
	current.setValue('assignment_group', gs.getProperty('groupXSysId'));
}
else if(variableValue == "y")
{
	current.setValue('assignment_group', gs.getProperty('groupYSysId'));
}
else if(variableValue == "z")
{
	current.setValue('assignment_group', gs.getProperty('groupZSysId'));
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader