- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 12:59 AM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 02:04 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 01:09 AM
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";
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 01:11 AM
Hello,
You can use Run script activity for this as below
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 06:50 AM
Thank you, it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 02:04 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader