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-16-2023 01:21 AM
Hi @ricker ,
Thanks for your reply. Could you help make this change? I have no coding knowledge yet, unfortunately.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 12:58 PM
Another option for this is to just use a client side GlideRecord query with a call back function to populate the data. I would go this way because its simpler and the DECISIONTABLE does not have many fields it looks like so the amount of data returned will not be much and the number of rows should be 1 or zero.
//Untested
//set this as the onchage client script for the location field. You also need to make sure
//that the DECISIONTABLE acl's allow everyone to read the table and the fields.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
//Check to make sure we have a new value just so we do not make an unneeded call.
if(newValue){
var dt = new GlideRecord("DECISIONTABLE");
dt.query("REGION", newValue, function(dt){
if(dt.next()) {
g_form.setValue("assignment_group", dt.GROUPFIELD);
} else {
//notifiy the user a group was not found.
g_form.addErrorMessage("A group was not found.");
}
});
}
}
Client side GlideRecord docs are here
https://developer.servicenow.com/dev.do#!/reference/api/sandiego/client/c_GlideRecordClientSideAPI?n...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 02:50 PM
Thanks @DrewW for looking into it. Do I use a callable script include with the onchange client script you've provided? How would that script include look like?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 08:01 AM
The code I suggested does not need a script include to work which is why I suggested it, to make things a little simpler. But as Sebastian points out it will not work in a scoped app which I assumed you were not using since this was for Incident Management.
If you still cannot get either solution to work you are going to have to post screen shots and the code you created I think otherwise I don't think we will be able to help you much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 08:25 AM
Hi @DrewW thanks for taking the time to help. Yes it's not a scoped app.
This is how I have the client script set up using your code. When choosing a caller on the incident form, I get the popup that no group could be found.