Skip to main content

SharePoint Ninja

Go Search
SharePoint Ninja
  

TechElixir > SharePoint Ninja > Categories
User list in infopath via the People web service
There has been a tricky problem in infopath for a while trying to get a user list in a drop down box. You can do this with the people web service. The problem has been it is almost impossible to find documentation on the thing and you have to know a few tricks to get it to work. Here are the steps from within Infopath.
Note: It only pulls people that have been to your sharepoint top level site.
 
1. Go to Design Tasks
2. Click on Data Source
3. Click on Manage Data Connections...
4. Once you are in the Data Connections Dialog box click Add
5. Choose Create a new connection and select Receive
6. Click Next
7. Choose Web Service
8. Click Next
9. Enter the url of the people.asmx web service (i.e. http://yoursite/_vti_bin/people.asmx)
10. Click Next
11. Choose Search Principals from the Select an operation: box.
12. Click Next
13. You are going to want to set the values for parameters.
14. tns:searchText should be your domain with a \ behind it (i.e. domain\)
15. tns:maxResults* should be a number greater than the results (i.e. 1000)
16. tns:PrincipalType should be the word User
17. click Next
18. click Next and then click Finish
19. Now you can click Close to close the Data Connection Dialog Box
20. Place a Drop-Down List Box on the form.
21. Under List box entries choose Look up values from an external data source
22. Choose SearchPrincipals as the data source.
23. Click on Entries
24. Expand until you see Principal Info and choose it
25. Choose DisplayName for DisplayName  and whatever field you want for Value (i.e. AccountName or DisplayName)
Getting a specific list view as a data source in Infopath

      1.       Create the view you intend to pull in SharePoint. Make sure to sort it and filter it the way you want it to appear in the drop down.

2.       Click on Settings->List Settings to get to the settings of the list you want to use.

3.       Scroll to the bottom where it shows views and click on the view that you want. This should be where you would edit the view.

4.       Go up to the URL and copy everything after List= (this is the GUID of the view).

5.       Place what you have in notepad.

6.        Replace %7B with { (this should be first part.

7.        Replace %7D with } (this should be the last part.

8.       Replace %2D with a –

9.       You should have something that looks like
{FCE658C5-54A5-4460-B9F4-6EE4CBF017D7}
Note:the numbers and letters are unique to your view but the formatting should be the same.

10.   Take the url of the site where the list resides and put it in front of the GUID

11.   Now you have the pieces to build your string. The format of the string is
<URL>/_vti_bin/owssvr.dll?Cmd=Display&List=<ListGUID>&View=<ViewGUID>&XMLDATA=TRUE
for example:
http://site/_vti_bin/owssvr.dll?Cmd=Display&List={FCE658C5-54A5-4460-B9F4-6EE4CBF017D7}&View={B9BC3880-739B-4DA0-89A7-716775E755B7}&XMLDATA=TRUE

12.   You now have the string you need to create the data connection in Infopath.

13.   In Infopath you need to add a data connection.

14.   Create a new connection to receive data. Click OK.

15.   Choose XML document. Click OK.

16.   Paste the string you created in notepad into the Enter the location of the XML data file that you want to use as your data connection.

17.   Click next and okay until you are out of the wizard and you are ready to use your data source. If you are given a security prompt you can just click cancel.

18.   Note: everyone that uses the form must have read access (at least) to the list you are pulling from.

Using Views for a graceful close in Form Services

If you have used Infopath in SharePoint Form Services you have probably run into the situation where you submit and then you are left with a couple of not so pretty options. You can close the form which leaves a big ugly form closed message, leave the form open, or open up a new form. None of those are what I would call optimal. What you can do is use a view when the person submits to show a nice friendly message.

Follow these steps.

1.       Create the form as you normally would.

2.       Click on the design tasks over on the right side and then click on Views.

3.       At the bottom you will see Add a new view… Go ahead and click on that.

4.       Name the view whatever you want.

5.       Add your “Thank you for submitting” text or whatever else you want on the page.

6.       Go back to the first view (i.e. View 1)

7.       Add a button or modify the submit button that you already have.

8.       View the properties of the button and make sure the Action is Rules and Custom Code.

9.       Click on the Rules button.

10.   Click Add.

11.   You want to add two actions. One is the Submit using a data connection. The other is Switch to view. Make the view switched to the one that you created in step 3. It should look something like this.

Rules

12.   Click ok until you get back