Monday, October 27, 2008

HOW TO Populate a List with the SharePoint Users

Introduction

In many cases, when filling in a form, some of the data must be user names. Users coming from SharePoint as you work together in a Team.

A possible scenario is to assign forms to colleagues like tasks or to use with a workflow within InfoPath.

This article will explain how to fill in a dropdown list with the SharePoint Users

Download

HOW_TO_Populate_a_List_with_the_SharePoint_Users.pdf

Compatibilty

Most of the information will be showed in a table and using symbols.

InfoPath 2003 clip_image001[4] Full support
InfoPath 2007 clip_image001[4] Full support
Desktop Browser clip_image002 No support
Mobile device browser clip_image002 No Support

Designing the Form

  1. Create a Receive Data Connection
    1. Go to Menu Tools -> Data Connections…
    2. Click the Add… button
    3. Select Receive data option
    4. Select SharePoint library or List
    5. Enter the Ur l of a SharePoint Site
    6. Select the Library or List

clip_image001 Note:

You can select any Library or Form, as we are going to change it later. The easiest way is to select a Library or list who has Title and ID as columns.
In case you don’t have Title, select Item

    1. Select only Title and ID (or Item and Id, see note above)
    2. Change the name of the Data Connection to SharePoint Users

clip_image003

Figure 1: Data Connection Wizard, selecting the columns

  1. Extract the Form Files
    1. Goto menu File -> Extract Form Files
    2. Select the folder to save the extracted form files
  2. clip_image005

  3. Figure 2: Browse for folder dialog box.

    1. Click Ok
    2. Close the InfoPath Designer
    3. Open the folder with the extracted files
    4. Open with Notepad the file Manifest.xsf
    5. Search for sharepointGuid
    6. Change the Guid with UserInfo

Code:

<xsf:dataObjects>

<xsf:dataObject name="SharePoint Users" schema="SharePoint Users.xsd" initOnLoad="yes">

<xsf:query>

<xsf:sharepointListAdapter siteUrl="http://mossqa.silversands.com/sites/Sandbox/infopath/" sharepointGuid="{799BD477-5183-4FAB-AE75-A9C45C870D4B}" infopathGroup="File_Attachments" queryAllowed="yes" submitAllowed="no" name="SharePoint Users">

<xsf:field sharepointName="Title" infopathName="Title"></xsf:field>

<xsf:field sharepointName="ID" infopathName="ID"></xsf:field>

</xsf:sharepointListAdapter>

</xsf:query>

</xsf:dataObject>

</xsf:dataObjects>

Change to

<xsf:dataObjects>

<xsf:dataObject name="SharePoint Users" schema="SharePoint Users.xsd" initOnLoad="yes">

<xsf:query>

<xsf:sharepointListAdapter siteUrl="http://mossqa.silversands.com/sites/Sandbox/infopath/" sharepointGuid="UserInfo" infopathGroup="File_Attachments" queryAllowed="yes" submitAllowed="no" name="SharePoint Users">

<xsf:field sharepointName="Title" infopathName="Title"></xsf:field>

<xsf:field sharepointName="ID" infopathName="ID"></xsf:field>

</xsf:sharepointListAdapter>

</xsf:query>

</xsf:dataObject>

</xsf:dataObjects>

    1. Right-click on Manisfest.xsf and Select design to re-open the form in Design mode
  1. Populate the Dropdown with the UserInfo
    1. Add a Dropdown list onto the Form
    2. Set the Field Name
    3. Select Look up values from an external datasource
    4. Select SharePoint Users in the Data Source drop down
    5. Select the repeating node using clip_image006 button next to the Entries textbox
    6. Set Value to @ID, by using the clip_image006[1] next to the Value textbox
    7. Set Value to @Name, by using the clip_image006[2] next to the Display name textbox
  1. Test the form, your doprodown box will be filled with the SharePoint Users

Conclusion

This article described how to populate a dropdown list box 8or other list boxes) with the users from SharePoint.

There are other ways of doing this, like using a web services, but this way you can keep everything in the design mode of the form

3 comments:

Unknown said...

After this article I have only one hundred recordings. But recordings count is more than one hundred.I don't know than's happened. Help, please!

Jimbo Alba said...

Many thanks for this post!

L01$Lan3 said...

Thanks so much for writing this...

Seems simple enough but I have no data... any thoughts?