Assignment group should be changed based on change of CI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 07:45 AM
Have a requirement
I have to populate the assignment group (eg:- test group) when i select any of the CI (eg:-a or b or c)
If i change the CI back to "mackbook air" then the Assignment group and Assigned to should be replaced back.
Can any one please help on this with script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 08:32 AM
Please see:
Client scripts (servicenow.com)
for one way to do what you ask. I see an example in my instance with name "Set assignment fields from table". You seem to want to set a specific value for the assignment group. If so, the logic is simpler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 10:03 PM
Hi
Can you share me the script please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 03:18 PM
Hi,
The client script I have is from the "Advanced Work Assignment" package. Screenshot is attached.
The script follows:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('TableFieldCheckerAjax');
ga.addParam('sysparm_name', 'tableHasField');
ga.addParam('sysparm_table_name', newValue);
ga.addParam('sysparm_field_name', 'assigned_to');
ga.getXML(TableFieldCheckerResultParse, [],
['assign_to_field', 'assigned_to', "Assigned to"]);
ga = new GlideAjax('TableFieldCheckerAjax');
ga.addParam('sysparm_name', 'tableHasField');
ga.addParam('sysparm_table_name', newValue);
ga.addParam('sysparm_field_name', 'assignment_group');
ga.getXML(TableFieldCheckerResultParse, [],
['assignment_group_field', 'assignment_group', "Assignment group"]);
function TableFieldCheckerResultParse(response, fieldNames) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var isFieldOnTable = (answer == "true"); // Ajax call returns string
if (isFieldOnTable) {
g_form.setValue(fieldNames[0], fieldNames[1], fieldNames[2]);
var span = document.getElementById("sys_display.awa_service_channel."+fieldNames[0]);
span.innerHTML = fieldNames[2];
} else
g_form.setValue(fieldNames[0], "");
}
}
You will need the GlideAjax logic if you want to query the sys_user_group table for values. if you know specific groups, you can use the 'g_form.setValue() method to set speficic values.