Fetch manager name from assignment group and show as field message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 09:10 PM
Hi Everyone,
Result ---Undefined
please assist me on this asap
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 09:36 PM
Refer the below link,
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 09:37 PM
Hi @Jyoti Ranjan Se ,
I would recommend making a glide ajax call instead since the getReference isn't something that is recommend and best practice.
Example one
Client script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('GetUserDetails'); // script include name
ga.addParam('sysparm_name', 'getManger'); // funcation name in script include
ga.addParam('sysparm_sys_id', newValue);
ga.getXMLAnswer(function(response) {
var userDetails = JSON.parse(response);
g_form.showFieldMsg('assignment_group', 'Change Manager: ' + userDetails.manager, 'info');
});
}
Script include: client callable true
var GetUserDetails = Class.create();
GetUserDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManger: function() {
var userId = this.getParameter('sysparm_sys_id'); // Get the Sys ID from the client script
var result = {};
if (userId) {
var userGR = new GlideRecord('sys_user_group'); // Query the sys_user_group table
userGR.addQuery('sys_id',userId);
userGR.query();
if(userGR.next()){
gs.log("getManger"+userGR.manager)
result.manager = userGR.manager.getDisplayValue();
}
}
return JSON.stringify(result);
},
type: 'GetUserDetails'
});
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 10:00 PM
Hi @Jyoti Ranjan Se ,
You can configure form and do dot walking to display manager.
Else you can go ahead with ajax call as suggested by @Bhavya11 .
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 12:33 AM
This is the output getting after written above script. please help me or assist