- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 12:35 PM
Hello, new to both ServiceNow and scripting. I have very slight experience with scripting, but not much. Anyway, my org is migrating to ServiceNow and I'm currently creating record producers. Most of our record producers automatically assign the assignment group based on the admin assignment group tied to the service/CI associated with the record producer. I'm creating one that I specifically need to have the assignment group assign based on a selection made by the end user. I've got this after doing some searching:
if (producer.VariableName== 'Value1') current.assignment_group = "Value1";
else if (producer.VariableName== 'Value2') current.assignment_group = "Value2";
else if (producer.VariableName== 'Value3') current.assignment_group = "Value3";
I've set the values of each of the 3 choices in the variable to be the assignment group. Problem right now is that the incidents that are being opened unassigned to any assignment group, not even the admin assignment group that's tied to the service for this record producer.
I tried doing some searching and testing other things, but I'm not having any luck. Wondering if anyone here can help out.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 02:08 AM
Hi Rob,
It sounds like you are saying the script you attempted isn't working. If that's the case, it would be helpful to see the actual script you used. From your example, be sure you are using the correct and exact (case-sensitive) names and values
1) VariableName must be the value from the Name column in your variable list
2) Be sure to use the Value of this variable selection, not the label. This will vary based on the variable type and your configuration. Reference variables store a sys_id, Select Box has a choice list with Text (label) and a Value. Show the variable type and setup if you are in doubt.
3) The value you are setting for assignment_group must be a group record sys_id as that is the value stored by a reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 02:08 AM
Hi Rob,
It sounds like you are saying the script you attempted isn't working. If that's the case, it would be helpful to see the actual script you used. From your example, be sure you are using the correct and exact (case-sensitive) names and values
1) VariableName must be the value from the Name column in your variable list
2) Be sure to use the Value of this variable selection, not the label. This will vary based on the variable type and your configuration. Reference variables store a sys_id, Select Box has a choice list with Text (label) and a Value. Show the variable type and setup if you are in doubt.
3) The value you are setting for assignment_group must be a group record sys_id as that is the value stored by a reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 06:36 AM
Hi Brad,
Thanks for your response! I was doing a little more digging and also took to heart your notes of exact case-sensitive values. If I remember correctly, this isn't a habit that I had to form from RemedyForce, so I'll need to make sure I break that habit while working here in ServiceNow. I was able to get this working after trying out a little change. Below is exact script of what worked for me:
if (producer.q_100_which_office_are_you_in == 'Americas_Canada') current.assignment_group.setDisplayValue( 'Americas_Canada');
else if (producer.q_100_which_office_are_you_in == 'ITSD_Americas') current.assignment_group.setDisplayValue('ITSD_Americas');
else if (producer.q_100_which_office_are_you_in == 'Americas_Des_Moines') current.assignment_group.setDisplayValue('Americas_Des_Moines');
Thanks again, I really appreciate the help. I do have a follow-up question, though, on your 3rd point. Why do some people say to use the sys_id here? Since I was able to get it working with the above (I'm using the Value field from the variable that is set to the exact "Name" of the assignment group and not the Text field of the variable), I'm wondering what the difference would be in using the sys_id of the assignment group instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 06:54 AM
You can use either:
current.assignment_group = '<<sys_id>>';
current.assignment_group.setValue('<<sys_id>>');
current.assignment_group.setDisplayValue('Americas_Canada');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 07:08 AM
Understood, thank you 🙂 I assume doing a sys id would be maybe preferred here in case there's a possibility of the value of the assignment group changing because the sys id would remain the same. I've got some questions to ask our integration partners regarding some things that came up during my trying to figure this out, anyway, so I can raise this with them, too. Thanks again, and have a great day.