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

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

Viewing 2 reply threads
  • Author
    Posts
    • #24537
      becca
      Participant

        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, 8 months ago by becca.
        • This topic was modified 5 years, 8 months ago by becca.
      • #24541
        becca
        Participant
          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.
        • #24544
          AdamP
          Participant

            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

            • #24546
              becca
              Participant

                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.