Solved

SharePoint user profile services

Posted on 2010-11-20
2
449 Views
Last Modified: 2012-05-10
I used the getuserprofilebyname() method to obtain information about the current user in InfoPath form.

My question is:
How can we pass in an account name or username to this data connection to obtain information (i.e. email addres, department, full name, etc) about other user(s)..?
0
Comment
Question by:sraj09
2 Comments
 
LVL 7

Assisted Solution

by:AlMothanaAlOmari
AlMothanaAlOmari earned 250 total points
ID: 34183029
public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            XPathNavigator root = this.MainDataSource.CreateNavigator();
            using (SPSite ospSite = new SPSite("http://sharepoint2010"))
   {
                try
                {
                    string uAccount =System.Environment.UserName;
                    string uManager;
                    string uPosition;
                    string uDepratment;

                    ServerContext ospServerContext = ServerContext.GetContext(ospSite);
                    UserProfileManager ospUserProfileManager = new UserProfileManager(ospServerContext);
                    UserProfile ospUserProfile = ospUserProfileManager.GetUserProfile(uAccount);


                   uManager= ospUserProfile["Name"].Value.ToString();
                   uPosition= ospUserProfile["Manager"].Value.ToString();
                   uDepratment= ospUserProfile["Department"].Value.ToString();
                   

                    root.SelectSingleNode("/my:VacationForm/my:EmployeeName", NamespaceManager).InnerXml =uAccount;
                    root.SelectSingleNode("/my:VacationForm/my:ManagerName", NamespaceManager).InnerXml = uManager;

                    root.SelectSingleNode("/my:VacationForm/my:Position", NamespaceManager).InnerXml = uPosition;

                    root.SelectSingleNode("/my:VacationForm/my:Department", NamespaceManager).InnerXml = uDepratment;

                   
                }

                catch (Exception ex)
                {
                   
                }
            }
0
 
LVL 15

Accepted Solution

by:
melli111 earned 250 total points
ID: 34187869
How is your form setup?  Assuming that a user is selecting lets say a manager somewhere and you're storing that account name, you would set a rule on that account name field.  the rule would be  "set a fields value" ... that value you would set would be the AccountName filed in the queryFields node of the GetUserProfileByName data source.  The value would be that username value that was just set on the field we're running the rule from.  Add a second action of "Query Using a Data Connection" to query the GetUserProfileByName service again... if you don't query it, it will not pull the new information.  

I hope that helps... let me know if you need any clarification.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now