How can you get manager name based on logged-in user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2021 08:11 AM
In the scoped application, I am not able to use 'javascript:gs.
Thanks
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2021 09:30 PM
Hope you are doing good.
Did my reply answer your question?
If so, please mark my response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2021 06:54 AM
This worked for me. I was trying to populate manager Name & manager level of the logged in user. This script helped me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2021 05:36 AM
Worked well for me, even for a Record Producer on a Reference Variable.
Thanks! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2021 09:14 PM
Hi Ankur,
Quick question - where do you add this script? I'm creating a basic catalog item where I am looking for:
- Requester Name
- Department
- Location
- Manager
I got the first 3 working - but can't figure out how to get the manager.
Catalog Client Script.
function onLoad() {
//Type appropriate comment here, and begin script below
}
var id = g_form.getValue('requested_for');
var ga = new GlideAjax('PopUserDetails');
ga.addParam('sysparm_name', 'findValues');
ga.addParam('sysparm_user_name', id);
ga.getXML(function ServerResponseParse(response) {
var result = response.responseXML.getElementsByTagName("result");
var department = result[0].getAttribute("department");
var user_id = result[0].getAttribute("user_id");
var location = result[0].getAttribute("location");
g_form.setValue('department', department);
g_form.setValue('user_id', user_id);
g_form.setValue('site', location);
});
Script Include:
var PopUserDetails = Class.create();
PopUserDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
findValues: function() {
var result = this.newItem("result");
result.setAttribute("message", "Returning user details");
var userInfo = this.getParameter('sysparm_user_name');
var userDetails = {};
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', userInfo);
gr.query();
if (gr.next()) {
result.setAttribute("department", gr.department.getDisplayValue());
result.setAttribute("location", gr.location.getDisplayValue());
result.setAttribute("user_id", gr.user_name);
result.setAttribute("title", gr.title);
}
return result;
},
type: 'PopUserDetails'
});
Not sure how to get the manager added in!
any help would be amazing.
Thanks
Clinton