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.