Fetch the manager of the selected assignment group and displays the manager's name as a field mesg
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 04:30 AM
Hi Everyone,
I want to show manager of assignment group under assignment group field as field message. how can i achieve this .
please help me on this.
Regards
Jyoti
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 04:59 AM
you can use onChange client script with GlideAjax and show the field message
Something like this
Script Include: Client callable
var GroupManagerUtils = Class.create();
GroupManagerUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManagerName: function() {
var groupId = this.getParameter('sysparm_group_id');
var group = new GlideRecord('sys_user_group');
if (group.get(groupId)) {
var manager = group.getDisplayValue('manager');
return manager;
}
return '';
},
type: 'GroupManagerUtils'
});
onChange client script on Assignment Group field:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue != oldValue){
var ga = new GlideAjax('GroupManagerUtils');
ga.addParam('sysparm_name', 'getManagerName');
ga.addParam('sysparm_group_id', newValue);
ga.getXMLAnswer(function(response) {
var managerName = response;
if (managerName) {
g_form.showFieldMsg('assignment_group', 'Manager: ' + managerName, 'info');
} else {
g_form.showFieldMsg('assignment_group', 'No manager found for this group', 'info');
}
});
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader