
- 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-01-2014 08:15 AM
Hi Yeny,
First of all remove assignment_group from Dependent field in the dictionary entry of the Assigned to field.
After that you will have to write a Before/Insert-Update BR that will Populate the Assignment Group field's value with the Group membership of the Populated Value of the Assigned To field. Keep in mind that if there is any BR that is assigning value to the Assigned To field, then keep your new BR's order greater than that of the current BR. Access the current.assigned_to's Assignment Groups by current.assigned_to.getMyGroups(), capture it in a variable and then assign that value to the Assignment Group field.
PS: I have not tested this but think that this should work
Regards,
Subhajit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2014 11:39 AM
Hi Subhajit,
Thank you, I tried what you suggested but it didn't work for me...
The BR that I wrote is the following:
when: before (insert/update)
condition: current.assigned_to.changes()
script:
var assignedTo = current.assigned_to.getMyGroups();
var assignment = current.assignment_group();
gs.setValue('assignment', assignedTo);
Did I not do it right? What am I missing?
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2014 09:59 PM
Use var assignment = current.assignment_group; instead of var assignment = current.assignment_group();
And yes, you can use default Assignment Groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 08:39 AM
hi subhajit,
can you tell me how to autopopulate assigned to field on the basis of assignment group field?