Reference Org Chart data for a user from a form using JS

Forums General discussion Reference Org Chart data for a user from a form using JS

Viewing 2 reply threads
  • Author
    • #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)

      • This topic was modified 5 years, 1 month ago by becca.
      • This topic was modified 5 years, 1 month ago by becca.
    • #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 = ("" + curuser);

      got the first part (unless someone knows a better way)

      • This reply was modified 5 years, 1 month ago by becca.
    • #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

      function getManager(){
      // Use this code in NewForm or EditForm
      ppData = spjs.utility.userInfo(login);
      // User profile is not available in SP Foundation
      userProfile = spjs.utility.userProfile(login).Manager;
      userProfileManager = spjs.utility.userProfile(login).Manager;
      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)


      • #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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.