- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 11:31 PM
Hi,
How to write on change client script to auto populate assignment group and assigned to based on caller on incident table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:49 AM - edited 01-17-2023 12:50 AM
@Alon Grod write an on change client script on called ID field and call a script include using glide ajax like below
Make sure your script include name is getStandardFields
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getStandardFields');//this is the script include
ga.addParam("sysparm_name", "getFields"); //this is the function within the script include
ga.addParam("sysparm_std", newValue);
ga.getXML(getResponse);
}
function getResponse(response) {
var values = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('assignment_group', values);
}
Script include :
Script Include: (Ensure the client callable checkbox is checked)
var getStandardFields = Class.create();
getStandardFields.prototype = {
getFields : function() {
var std = this.getParameter('sysparm_std');
var standardFields = new GlideRecord('sys_user_grmember');
standardFields.orderBy('sys_created_on');
standardFields.addQuery('user', std);
standardFields.query();
if(standardFields.next()) {
return standardFields.group.toString();
}
},
type: 'getStandardFields'
};
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 11:35 PM
Hello @Alon Grod ,
so when you select caller you need to populate assignment group and assigned to ?
if yes whats the criteria to populate do you have any specific group and user ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:19 AM
@Mohith Devatte its based on the first group that the user belong to from the sys_user_group table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:49 AM - edited 01-17-2023 12:50 AM
@Alon Grod write an on change client script on called ID field and call a script include using glide ajax like below
Make sure your script include name is getStandardFields
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getStandardFields');//this is the script include
ga.addParam("sysparm_name", "getFields"); //this is the function within the script include
ga.addParam("sysparm_std", newValue);
ga.getXML(getResponse);
}
function getResponse(response) {
var values = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('assignment_group', values);
}
Script include :
Script Include: (Ensure the client callable checkbox is checked)
var getStandardFields = Class.create();
getStandardFields.prototype = {
getFields : function() {
var std = this.getParameter('sysparm_std');
var standardFields = new GlideRecord('sys_user_grmember');
standardFields.orderBy('sys_created_on');
standardFields.addQuery('user', std);
standardFields.query();
if(standardFields.next()) {
return standardFields.group.toString();
}
},
type: 'getStandardFields'
};
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 11:36 PM - edited 01-16-2023 11:38 PM