«

»

Sep 17

Creating a people picker form in InfoPath 2010

The School I work at is undertaking a massive project to try and remove all forms of unnecessary paperwork. You know the ones

  • Course request
  • Cover request
  • Leave of absence
  • Duty swap

 

These are only a few, not counting the paperwork we send home to parents. So we decided to start small to see how it worked, could we make it simple and would staff cope with the changes.

I am going to break the process down into a series of post otherwise it would be a very long read. This first one is going to explain how to add a People Picker control and submit the form as an email.

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 domainusername 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.

7 comments

2 pings

Skip to comment form

  1. Troy Weis

    This is a great post, and everything works perfectly. But what would the formula look like if you could select multiple people in the people picker? I am only able to get the first person in the list to show up in the email. Any suggestions?

    1. arichards_Saruk

      To be honest I have had exactly the same issue and at the moment not found a solution

      1. Andy

        Did anyone find a solution for picking more than one person?

  2. Chan

    Hi arichards,

    Did you find the solution for the multiple people in the people picker, please let me know if you have the solution.

    Thanks!

  3. ahmet

    hi is there any way to use person picker without sharepoint server. or is there any way to connect GAL when there is no sharepoint server.
    thanks

    1. arichards_Saruk

      The people picker in InfoPath actually uses the user profile service in SharePoint so without that working it won’t find anything

  4. Johnny

    Click the General tab in the Person/Group Picker properties. Check the “Allow multiple selections” box. This will allow you to pick more than one person.

  1. Creating a people picker form in InfoPath 2010 - Learning Gateway Partner Blog - Microsoft Education Community

    [...] September 2010 (4)August 2010 (2)July 2010 (13)June 2010 (13)May 2010 (2)April 2010 (8)March 2010 (21)February 2010 (10)January 2010 (9)December 2009 (1)November 2009 (2)October 2009 (12)September 2009 (16)August 2009 (3)July 2009 (4)June 2009 (4)May 2009 (12)March 2009 (4)August 2008 (1) The School I work at is undertaking a massive project to try and remove all forms of unnecessary paperwork. You Read the Rest… Read More… [...]

  2. Nilesh Rathod

    [...] http://www.edutechnow.com/?p=446 [...]

Leave a Reply