Assignment group autopopulate based on service field in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 04:41 AM - edited 05-06-2024 04:42 AM
Hi All,
I have a field in the record producers " Create incident" Application name which is reference filed of business Service .
As per the selection of the CI / Application name whenever the incident form is submitted from the Service portal the incident has to get assigned to the Application name respective support group.
When an incident is created in platform as per the selection of Ci/Application name the assignment group is getting auto populated as there is onchange client script and Script include . I need same thing to happen when user creates incident from Service portal as well that is record producer .
The script include for Platofrm is :
u_taskAjax = Class.create();
u_taskAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getassignmentgroup: function() {
var trgt = this.getParameter('sysparm_target');
var serviceGR = new GlideRecord('cmdb_ci_service');
serviceGR.addQuery('sys_id', trgt);
serviceGR.query();
if (serviceGR.next()) {
return serviceGR.support_group;
}
},
type: 'u_taskAjax'
});
Onchange client script for platform:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//To auto populate assignment group based on services.
var business_service = newValue;
var businessServiceAjax = new GlideAjax('u_taskAjax');
businessServiceAjax.addParam('sysparm_name', 'getassignmentgroup');
businessServiceAjax.addParam('sysparm_target', business_service);
// submit request to server, call ajaxResponse function with server response
businessServiceAjax.getXML(subAjaxResponse);
}
function subAjaxResponse (response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('assignment_group', answer);
g_form.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 04:46 AM
Why scripts calling scripts? Why not just use assignment rules: set incident assignment group to support group of application. One rule to ring them all.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 02:33 AM
Though i have achieved the required thing , however would like to understand how we can achieve the auto populate assignment group based on Service field without using Onchange client script and Script Include .
Happy for learning new ways .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 04:46 AM
@ServiceNow10sun Instead of doing this via client script, you should use an Assignment rules to automatically assign an incident to an assignment group. For more information on assignment rules please refer to https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/task-table/c....
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 02:30 AM
Assignment rule we can use when we have limited number of options and we can write those assignment rule , however when we have many conditions like in this case its applications available in cmdb_ci_service table which keeps on adding in the table so we cannot write so many assignment rule , hence i have chosen script include and onchange client script .
and Assignment rule i have noticed it will show the assignment group after we save the record , however onchange client script is showing immediately when we are changing the Ci in application name.