Client script for manager's manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 05:00 AM
We have two fields- user , manager's manager.
In user field - if we enter abel tutor name approval will trigger to Abel tutor manager.ex: abhraham lincoln (configured through flow)
In manager's manager field- it should be trigger to abhraham lincoln manager.
Need client script for this. It should autopopulate manager's manager based on user field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2024 05:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 08:51 AM
Hi @User_267 ,
Please make changes to below script as per your requirement:
Script Include: make sure Client callable is set to true on your Script Include
var GetUserCustomUtils = Class.create(); GetUserCustomUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, { getUserManager: function() { var manager_name = ''; var userID = this.getParameter('sysparm_caller_id'); var userGR = new GlideRecord("sys_user"); if (userGR.get(userID)) { manager_name = userGR.getDisplayValue("manager"); } return manager_name; }, type: "GetUserCustomUtils" });
Create onchange client script Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } var ga = new GlideAjax('GetUserCustomUtils'); ga.addParam('sysparm_name', 'getUserManager'); ga.addParam('sysparm_caller_id', g_form.getValue('caller_id')); ga.getXMLAnswer(parseResponseData); } function parseResponseData(response) { var managerName = response; g_form.setValue('short_description', managerName); }
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda