- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 01:35 AM
I want to auto populate group manager name in group manager field from sys_user_group table on selecting group in catalog form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 03:42 AM
Hi @Pranay Verma,
If group manager variable is reference field then you will get manager name in the reference field
if you are using string field then need to use Glide Ajax. Send the sysid to the script include, query the tables and return all the display values.
Try this below code
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('groupManager');
ga.addParam('sysparm_name','getManagerName');
ga.addParam('sysparm_manager',g_form.getValue('group'));
ga.getXML(callBackFn);
function callBackFn(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('group_manager',answer);
}
}
script include:
var groupManager= Class.create();
groupManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManagerName : function(){
var group_id = this.getParameter('sysparm_manager');
var group = new GlideRecord('sys_user_group');
if(group.get(group_id)){
return group.manager.name;
}
},
type: 'groupManager'
});
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 01:43 AM
Hi @Pranay Verma,
Try to use on change client script
on change variable : group
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var manager = g_form.getReference('group').manager;
g_form.setValue('group_manager',manager );
}
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 01:46 AM
write below code in reference qualifier of your Group manager field
javascript:current.variables.group.manager;
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 03:10 AM
We are getting the sysid of the manager but not the manager name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 03:42 AM
Hi @Pranay Verma,
If group manager variable is reference field then you will get manager name in the reference field
if you are using string field then need to use Glide Ajax. Send the sysid to the script include, query the tables and return all the display values.
Try this below code
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('groupManager');
ga.addParam('sysparm_name','getManagerName');
ga.addParam('sysparm_manager',g_form.getValue('group'));
ga.getXML(callBackFn);
function callBackFn(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('group_manager',answer);
}
}
script include:
var groupManager= Class.create();
groupManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManagerName : function(){
var group_id = this.getParameter('sysparm_manager');
var group = new GlideRecord('sys_user_group');
if(group.get(group_id)){
return group.manager.name;
}
},
type: 'groupManager'
});
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
Mohan.