How to automatically populate assignment group field based on caller location BEFORE saving?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 06:10 AM - edited 01-11-2023 06:10 AM
Hi,
How do I make the incident form automatically populate the assignment group field based on the location of the caller before even saving the form?
Use case: I'd like the assignment group field to be immediately filled with the service desk of the caller's respective location from the moment the location is selected on the form.
There is a decision table that links the location with the assignment group, see picture in attachment.
How do I go about doing this? Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 06:22 AM
OnChange Client Script + Script Include
in Client Script
var location = g_form.getValue("location") //give the proper column name;
var ga = new GlideAjax('populateAssignmentGroup'); //Give proper script include name and it should be client callable script include
ga.addParam('sysparm_name', assignmentGroupCheck);
ga.addParam('sysparm_location',location);
ga.getXML(callback);
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
g_form.setValue("assignment_group", answer);
}
}
In Script Include
var populateAssignmentGroup = Class.create();
populateAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
assignmentGroupCheck: function () {
var location= this.getParameter('sysparm_location');
//write your logic to get the assignment goup based on loaction
return assignmentGroup
}
}
});
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 06:41 AM
Basheer's answer is very good. Just a few clarifications and other things you may want to do:
- The client script is onChange of the caller_id or location field? It is up to you. You may have another client script filling in the location field once you provide the caller_id. So this will be like a daisy chain event: you provide the caller_id, then the location is populated with the correct information and this new client script uses the location field to determine the assignment group.
- You will have to use the decision table information into the script include's logic
If I helped you with your case, please click the Thumb Icon and mark as Correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 06:56 AM
Yes there is a dictionary entry override that automatically fills the location of the caller in the incident form. Does this interfere with anything? How do I use the decision table info into the script include?
Apologies for all the questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 07:34 AM
So you are telling me that if you change the caller_id many times on the form the location field changes accordingly? That cannot be because of a dictionary override...
The decision code would be something like:
var gr = new GlideRecord('decisiontable'); //I assume that is the name of the table
gr.addEncodedQuery('region=location'); //assuming location is the same as the regions on that table
gr.query();
return gr.group;
}
If I helped you with your case, please click the Thumb Icon and mark as Correct.