Recent Posts

Wednesday, August 22, 2012

How to include people picker in Microsoft infopath 2010 (Step by Step)

I have started working on InfoPath 2010 and since it is new to me I was looking for ways to work with the People Picker control in Microsoft infopath 2010 so that it picks up the employee information from the Sharepoint server and that will in-turn provides people information that is stored in active directory.

So in this hunt of articles for me to help I found this brilliant article on the web called: Creating a people picker form in InfoPath 2010 by Alan

So I couldn't resist the article and published it here as well, hope he doesn't mind as i have used all his screenshots

Duty Swap

We decided to go with the duty swap form to start with, its currently a paper form that staff complete when they swap a duty with someone. The paper form is supposed to be a reminder that the swap has taken place and a copy goes to the duty team leader
Let me show you the finished article and then I can explain each step.
image

Creating The Form

Open InfoPath, in my case its InfoPath 2010
image
Select SharePoint Form Library and click Design Form
image
You can now edit all the headings etc to suit your needs and then lets add a people picker control and text box

Adding Controls

To access the controls, expand the control section on the menu bar and select them from the list
image
Your screen will now look like this
image
On the right hand side you will now have a list of the fields you have just added, however they are not named very well
image
Double click the field heading and change the names to something relevant
image

Testing The Form

With these two controls added we can test the form, to do this click on the Preview button at the end of the ribbon
image
If you type into the people picker control however, you will get an error
image
This is because the control has nothing to talk to. During runtime it will talk to the SharePoint site the form is published to and use the user profiles service to retrieve users details. To overcome this issue while we design the form we need to tell it the URL of the SharePoint site. To do this double click on the people picker control and select Control Properties
image
Click on the SharePoint Server tab and enter the address of the server
image
Now when you preview you the form it will return the username
image

Creating A Formula

We now need to fill in the text box with the email address of the user. This is going to require a formula to take details from the people picker control
If you look at the people picker control it pulls through the following data
  • DisplayName
  • AccountId
  • AccountType

We can use the AccountId to produce the email address, if you use InfoPath to complete the form you can use the AccountId to send the email but we are going to fill the form in using a web browser so we need to produce a full email address.
Double click on the text box control and select control properties from the ribbon
image
Click on the fx button
The AccountId will be returned from the system in the format of domain\username we need to take this and use just the username to add to the email address. For this we will need to use two functions
  • substring-after – This function looks at the AccountId field and only uses the text after the \
  • concat – This function concatenates (joins together) the selected text from the AccountId and the rest of the email address

Here is the code and as it should appear on the screen
concat(substring-after(AccountId, "\"), "@westhatch.essex.sch.uk")
image
So now lets see what happens when we use the people picker to search for a user
image

Submit The Form

Our form now has enough information in it for it to be submitted to someone by email. In this example it will be setup to submit an active view of the form to the user selected in the people picker
To do this we need to create a data connection to submit the form
From the ribbon select the Data tab and then click on To E-mail
image
Click on the function key next to the To: text box
image
Click on Insert Field or Group and select the text box field that will contain the email address
image
Select the option to send only the active view of the form
image
Give the data connection a name and then click Finish
image
Now lets preview the form again only this time click Submit once you have selected someone in the people picker
image
Once you click on Submit you should receive an email with the active view of your form like the one below
image
So we have a form that will allow the user to find people from within the organisation and then submit the form as an email to that user. That’s great but it doesn’t really do anything else. Part 2 of this series will add more controls and as well as submit the form as an email will save the data to SharePoint for further analysis.

Thanks Alan can't wait for your part 2 and if i figure this out then I will try to post the part 2 version of this asap.

Cheers

Related Posts by Categories




1 comment:

Anonymous said...

I ADAMS KEVIN, a representative Aiico Insurance plc, we trust and respect for individual differences in day out a loan. We will provide 2% of the loan's interest rate. If you are interested in this business contact us by e-mail: (adams.credi@gmail.com) now transfer their loan documents issued properly. Do you need a loan to set up business or school if you are very welcome to Aiico Insurance plc. You can also contact us by e-mail: (adams.credi@gmail.com). We first week can request a balance transfer.

DO YOU NEED LOAN FOR PERSONAL BUSINESS? IF YOU CONTACT YOUR EMAIL ABOVE TO PROCEED WITH YOUR LOAN TRANSFER IMMEDIATELY OK.

Post a Comment