
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2014 07:32 AM
Hello!
I am trying to write a script to populate the assignment group when the assigned to field has a name in it. For example, Jane Smith belongs to group Infrastructure. I assign an incident to Jane Smith and the assignment group changes from empty to "Infrastructure" since that is the group she belongs to. I am new to Service Now and I'm not too familiar with the java script. I'm thinking I will have to write an Assignment Rule but I am not sure on how to start it. Also, we have the "Assign to Me" button on the Incident form and would like the button to do the same. If I click on "Assign to Me",the incident will be assigned to me and the assignment group will be auto-populated with my group.
for the button, in the UI Action, I had this:
action.setRedirectURL(current);
current.assigned_to = gs.getUserID();
current.assignment_group = gs.getMyGroups();
current.update();
However, that is not working for me.
I would like some help in figuring out how I can accomplish this. Please let me know what I can do.
Thank you!!!
Yeny.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2014 10:19 AM
Hi Yeny,
You will need to ensure that you have scripts enabled for mobile devices.
Configuring the Smartphone Interface - ServiceNow Wiki
Since it sounds like you need to have the Assignment group populated in real time and not in a business rule, the only suggestion I would have for that is an onChange client script for the Assigned to field. That script could run an asynchronous GlideAjax call to perform the same function that is in the business rule that I suggested. The return value from that script will be the assignment group and by using "g_form.setValue(<field name>, value)", you can have the assignment group populated.
You could also use "g_form.getReference(fieldName, callback)" with the callback function so not to hang the client on the script processing. In the callback function, the return value can also be set by using "g_form.setValue(<field name>, value)"
Mobile Client GlideForm (g form) Scripting - ServiceNow Wiki
In regards to your UI Policy with the Service Desk value, you can condition it out to not clear the value if the assigned to is empty and the assignment group is Service Desk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2015 12:10 AM
Hi Hervinder,
You can make your Assigned To field dependent on the Assignment Group column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2014 11:59 AM
One thing to think about here - not every user will be listed in only one group. That may complicate what you are trying to accomplish.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2014 12:23 PM
Hi John,
Yes that is true... some of our users will be in several groups... so I'm guessing we'll have to have default groups for them? So whenever the action is executed, the system knows to pull the default group assigned to them and if needed, the user can manually change it to a different one and save... But I am not sure how to do that or if it's possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2014 02:36 PM
I would say that you can add a reference field to your user table to set your default group.
Then in your business rule, query the user table and get just the record for that "assigned_to" user and populated what is placed in the Default Group reference field.
Example:
On the User Table: New Reference Field "Default Group (u_default_group)"
In the BR:
when: Before - update/insert
condition - current.assigned_to.changes();
script:
setDefaultGrp(current.assigned_to);
function setDefaultGrp(assignedTo){
var defGroup = new GlideRecord('sys_user');
defGroup.get(assignedTo);
current.assignment_group = defGroup.u_default_group;
}
I hope this helps. Let me know!
Kind Regards,
Mike

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2014 12:09 PM
Hi Mike,
So I did what you told me and created a reference field in the user table and added the business rule. It works perfectly doing what it's supposed to do. However, I have some other issues.
One is that the assignment group field is mandatory in the incident form and I would still have to type something in the field in order to have the business rule run... I could turn this into a client script but it wouldn't work in the mobile UI for us so that's not going to work... do you have any suggestions on that?
Also, I need to write script or have something that clears out the assignment group when the assigned to field changes to another name or is empty and vice versa.... I tried to do this with a UI policy but it conflicts with the new incidents created from the protal, since they are assigned to the Service Desk when they are first created but then the UI Policy kicks in and clears out the assignment group field since assigned to is empty. What do you suggest on that one?
Any help you can provide is greatly appreciated!!!