Home › Forums › General discussion › Reference Org Chart data for a user from a form using JS
- This topic has 3 replies, 2 voices, and was last updated 5 years, 8 months ago by becca.
-
AuthorPosts
-
-
March 29, 2019 at 16:07 #24537
I have a form that fills in 4 people fields based on the current user to return name, account, phone, and email (pretty simple stuff) but the 5th field is for the user’s manager. None of the ways to display people fields returns anything useful for this, but we do use Org Charts on our user pages that shows their manager. I want to reference the user’s page and the Org Chart within to get their manager, but I’m not sure how.
I’m thinking something along the lines of
[set variable with user account]
[translate symbols to ascii codes]
[append new user account string to end of url for user page]
[reference the Org Chart on the user page]
[set field to be manager's name or user account]I just don’t know how to do this with JS, could someone help me?
(the person working on this form uses InfoPath instead of DFFS so it would be nice to know how to do this in InfoPath, but I prefer DFFS so just knowing how to via JS is good enough for me)
-
March 29, 2019 at 16:59 #24541
var curuser = {accountfieldinternalname}; curuser = curuser.replace(":","%3A"); curuser = curuser.replace("#","%23"); curuser = curuser.replace(".","%2E"); curuser = curuser.replace("|","%7C"); curuser = curuser.replace("\","%5C"); var upageurl = ("oururl.com/accountname=" + curuser);
got the first part (unless someone knows a better way)
- This reply was modified 5 years, 8 months ago by becca.
-
March 29, 2019 at 17:11 #24544
I’ve got a people picker field that I use to get the manager ID from directly from the person’s profile properties. I cant remember exactly what I did to create the code, but it was probably based on https://spjsblog.com/forums/topic/pull-user-info-from-a-people-picker/
function getManager(){
// Use this code in NewForm or EditForm
$.each(spjs.utility.getFieldValue({“fin”:”Employee”,”key”:”loginName”}),function(i,login){
ppData = spjs.utility.userInfo(login);
//console.log(ppData);
// User profile is not available in SP Foundation
userProfile = spjs.utility.userProfile(login).Manager;
userProfileManager = spjs.utility.userProfile(login).Manager;
//console.log(“Manager:”+userProfileManager);
setFieldValue (“Manager”,userProfileManager);
});
};I then call getManager with an on change rule for the Employee people picker. The manager gets written to the manager people picker (read only)
Adam
-
March 29, 2019 at 17:40 #24546
This is beautiful, THANK YOU. I didn’t think .Manager was an option and was fully prepared to pull the name out of the html in the org chart, this is perfection.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.