Clayton's SharePoint Madness

All About SharePoint, InfoPath, and SharePoint Designer!

InfoPath – Get Manager Information

Posted by Clayton Cobb on June 21, 2009

This does not contain separate information, but I wanted it to show up for people doing searches while trying to figure out how to get Manager information from Active Directory.  I see this question a lot, and it is touched on in great detail in this blog entry:  InfoPath – Get user information without writing code (extended).  That entry contains additional info, so I just wanted to get this blog title out there for people to find.

14 Responses to “InfoPath – Get Manager Information”

  1. solidago said

    I have ready 100s of blogs on the web, and I’m missing something. I know I’m close but just missing something minute. Not sure this is the most efficient way. A person launches an infopath form. In the form using contact select, they pick a staff member. When they select that staff member, I would like to extract somehow that person’s email address. I understand that using the geruserprofilebyname and the contact select, this can be done, haven’t figured out how to do it. Once the email address is prefilled when the user selects the staff member, upon submission, the form should be send to that email address for revivew and approval using another ‘view’ of the form. I hope this work process makes sense. Right not I’m stuck populating the field with the email addresss of the staff member selected. thanks

    • Clayton Cobb said

      Solidago, your scenario is valid and can be made to work quite easily once you know all the pieces. What you need to do is when the contact selector gets resolved with a name, realize that the AccountId node of that Contact Selector has the user’s domain name in this format: domain\username. You need to strip out the username with substring-after(AccountId,”\”). This gives you just the username. For example, domain\ccobb becomes ccobb. You then use rules to set the value of the QUERY (not DATA) parameter on the GetUserProfileByName web method to this username and immediately query afterwards. This will return the profile data set for the user in the Contact Selector, including the WorkEmail attribute. You can easily save this value to a field in your form using a rule or default value. Then, create a new view and in the Form Load rules (Tools > Form Options > Open & Save > Rules), set a rule that switches to that other view if the current user equals the user in the contact selector. Also, in your workflow (SharePoint Designer preferably), you can auto-send the notification email to the WorkEmail value retrieved above.

      For what it’s worth, I do this in almost every form, so you should be good.

  2. solidago said

    Hi Clayton, thank you so much for your quick response. I’m using a blog instructions with the double eval statement, and can’t get pass this error msg. Any help would be appreciated. I’ve retyped the statement too, but that does not help. thanks

    Reference to undeclared namespace prefix: ‘my’.
    Error occurred during a call to property or method ‘Eval’.


    xdMath:Eval(xdMath:Eval(my:Contacts/my:Person, ‘concat(my:AccountId, “|”)’), “..”).

    • Clayton Cobb said

      I also use the Double Eval trick. It only works if your syntax is perfect and when it matches your data structure. Your error is telling us that MY is not the proper namespace. Is your namespace named something else than MY?

      • solidago said

        I’m sorry…but I’m okay with the ‘my’ namespace. Isn’t this what is automatically used by the system. I just started with creating this infopath form, and don’t know much about namespaces. How/where do I find the correct namespace for this form, so that I can change the formula. thank you.

      • Clayton Cobb said

        In your main data source, what is the name of the top-level folder? Is it still myFields? If so, then your namespace should be MY, but it still depends on how you’ve built the data structure. If you go to any field, go to its properties, then click the function builder button for the default value, then you can select any field (i.e. your Person/AccountID field), then click the checkbox for Edit XPath. This will show you the XPath for that field and should help ensure your syntax is correct for the Double Eval trick.

        This stuff can be very tricky. You have to make sure that when you copy someone else’s XPath statement that it matches your data structure exactly, which often means knowing how to change the syntax to suit your form template. Feel free to send me your template (.XSN) for me to review the data structure.

  3. solidago said

    Thanks…I copied the schema in twice to this blog, and I receive page with just the words ‘discarded’ . Let me try again. yes, it is called myFields. When i follow your instructions, I couldn’t find a formula for AccountId, however, here it is for field “Title”. I know you can unravel something out of this. I appreciate your patience…!

    xdXDocument:GetDOM(“GetUserProfileByName”)/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = “Title”]

    Also, here is the snippet for the contact select

    • Clayton Cobb said

      Title doesn’t help – I’d need it for the nodes of your Contact Selector, which is what you’re referencing in the Double Eval. It would be easiest if I could see the XSN (via email).

  4. solidago said

    okay…your email address please…I assume I can’t reply to the email that I receive..
    Is the .XSD file what you would like to see? thanks

  5. pitsta said

    Hi Clayton, I have read quite a few of your blogs and they have been extremely helpful – so thank you. I have stumbled apon an issue that I can not solve. Hoping you can provide an insight.

    Problem: I am creating a company form that auto populates the current user – using GetUserProfileByName data connection and this is great. the issue I have is that I have a second Person Picker – and this field auto populates another field with that users managers details (not the current user – but the selected user from the person picker) This updates fine when a user is selected. BUT – when the form is opened again the manager details is changed to the current users’ manager.

    I have used two GetUserProfileByName data connections – one for the current user and the second for the selected user (so I can get all the managers details – ie. PreferredName, email etc)

    Hope this makes sense.

    thanks in advance

    • Clayton Cobb said

      Shaun, I’m guessing it’s because your 2nd data connection is set to “automatically retrieve,” which means it retrieves the current user’s data on form load, which then triggers your other rules.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: