Using Sharepoint UserGroup Web Service with InfoPath Forms Service

When you create a data connection to the UserGroup Sharepoint Web Service and select the GetUserCollectionFromGroup method, Infopath doesn’t interpret the results correctly and you can’t use the data connection in a Drop Down List control. I’ve seen examples which use code to get around this problem, but I’m using the Forms Service so code is not an option. We need to modify Infopath’s xsd file of the web service data connection to fix the problem.

In the example below I will create a data connection to the http://moss/_vti_bin/usergroup.asmx web service to receive data to use in a Drop Down List to pick from the members of a Sharepoint Group.

1. Create the Data Connection

2. Select Web Service

3. Enter the URL to the UserGroup web service, don’t forget to include your site in the URL if appropriate.

4. For this example I’m using the GetUserCollectionFromGroup method

5. Provide InfoPath with an example Group Name
6. Provide InfoPath with the actual Group Name you want this Data Connection to query
7. Choose if you want to store a copy of the data in the form template for use in Offline mode. Since I’m using the Forms Service the form will never be used offline, so I’m leaving the box unchecked
8. Give your new Data Connection a name and Finish the wizard

Next we need to save the Form so we can manually edit the XSD for the Data Connection. From the File drop down manu choose Save as Source Files…
Open the folder where you saved the Form and you should see a Developers1.xsd file, edit this file with your favourite XML Editor (or notepad). Update the file so it looks like the snippet below, I’ve put in a comment at the start and end of the modification.

<schema elementformdefault="qualified" targetnamespace="" xmlns:http="" xmlns:mime="" xmlns:s="" xmlns:soap12="" xmlns:soap="" xmlns:soapenc="" xmlns:tm="" xmlns:tns="" xmlns:wsdl="">
 <complextype name="GetUserCollectionFromGroupType">
   <element maxoccurs="1" minoccurs="0" name="Users">
      <element maxoccurs="unbounded" name="User">
        <attribute name="Notes" type="s:string"></attribute>
        <attribute name="Name" type="s:string"></attribute>
        <attribute name="IsSiteAdmin" type="s:string"></attribute>
        <attribute name="Sid" type="s:string"></attribute>
        <attribute name="ID" type="s:string"></attribute>
        <attribute name="LoginName" type="s:string"></attribute>
        <attribute name="Email" type="s:string"></attribute>
        <attribute name="IsDomainGroup" type="s:string"></attribute>
 <element name="GetUserCollectionFromSite">
We need to change another part of this file, replacing a s:element block.
<!--<s:element name="GetUserCollectionFromGroup">
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
<!-- Beginning of insert -->
<s:element name="GetUserCollectionFromGroup" type="tns:GetUserCollectionFromGroupType" />
<!-- End of insert -->
Now save the Developers1.xsd file, right click on the Manifest.xsf file and choose Design.

Add a Drop Down List Control and set its Data Source to Developers, you should now be able to select the correct attributes returned from the web service.

You can Save the Form as a standard XSN file, but DO NOT edit the Developers Data Source in InfoPath or you will overwrite the changes made to the Developers1.xsd file.


stephaniedehart said...

I'm using InfoPath Designer 2010 and trying to follow your example here, but the .xsd file that infpath generates looks nothing like the one in your example. I'm guessing you used InfoPath 2007, because in 2010 you can't do Save As Source Files. You have to go under Publish, and then Export Source Files.

Anyway, in your post you say, "Open the folder where you saved the Form and you should see a Developers1.xsd file, edit this file with your favourite XML Editor (or notepad). Update the file so it looks like the snippet below, I’ve put in a comment at the start and end of the modification." But there aren't any comments to mark the start and end, and since my file is nothing like yours I can't tell what you changed. I can post my whole file if it helps, but it's pretty big.

Would you mind marking what you changed in your first snippet like you did in the second one?

Ian said...

This was done using InfoPath 2007. I think it was the list of attributes that I added in the first snippet, but I can't be sure. Would you be able to try this using InfoPath 2007 and then you should be able to see what changed ? I don't have access to a copy of InfoPath 2010, if I did then I would write an updated blog entry that shows the process for 2010.

Hamid said...

Hi Ian,

I have done everything you have said up to the point I have to open the manifest file in design mode. However, I get this error and infopath doesnt allow me to open the manifest:

Infopath cannot open the following form: C:\manifest.xsf
The XML schema specified in the form definition (.xsf) file for dataObejct "Developer" cannot be used.

I have tried to change the file several time to make it like yours however I keep getting this error.
do you have any idea where i am wrong?


anaolala said...

Yes, I have the same problem as Hamid does, everything is ok till I try open manifest. xsf


Anonymous said...

Hi Ian,

Would it be possible for you to display the entire developers1.xsd file with this article? I'm trying to make the changes illustrated and it's not working. I'm pretty new to XML, though, so I'm sure it's something I'm doing wrong. Any help would be appreciated!

Anonymous said...

I followed each but I also get the "...cannot be used"

Hope you can enlighten us..

Brendan said...

For SharePoint 2010, you have to paste your snippet for the element underneatht he IMPORT statement at the top of nameOfService1.xsd (where nameOfService is the name for your data connection) and then follow instructions as normal within that file and all is well. Just be sure to UNcheck the 'automatically query this data source' option and then SET the userLoginName under the 'queryFields' in your data connection in InfoPath.

George said...


that solution didnt work for me. I still get "The xml schema file specified in the form definition (.xsf) file for data Object "GetUsercollectionFromGroup" cannot be used" error.

Anybody found a solution for that issue or a workaround?
I know for most people this article worked without a hitch, so I'm interested in finding out why it doesnt work for me.

Edwin Roestenburg said...

For me it helped to change capitalizatin (minOccurs, maxOccurs, complexType)

Lars said...

I agree with Edwin about capitalizing the complexType tags and minOccurs attribute names, as well as adding the "s:" prefix to all tags. And run an XML validator to make sure your file is valid.

bllittle said...
This comment has been removed by the author.
bllittle said...
This comment has been removed by the author.
bllittle said...
This comment has been removed by the author.
Anonymous said...

Watch for

already in the file.

Also, the schema tags (top/bottom) aren't needed and case is important.

NeveraNullMoment said...

Hey All,

I got this working in InfoPath 2010 customizing a SharePoint list form. Basically, follow the instructions here:

There are two files you need to modify: (1) dataconnectionname.xsd and (2) dataconnectionname1.xsd.

Follow the instructions in my link I referenced for the dataconnectioname1.xsd file. You just need to replace the one element.

Hope this helps someone!

Alison said...
This comment has been removed by the author.
Alison said...

I resolved the manifest error by adding a closing element tag to the s:element name="GetUserCollectionFromGroup" type="tns:GetUserCollectionFromGroupType"

MOF said...

thank you for great artical, but i am getting an error in step number 6,when i add sample vale for sharepoint group name, the error Group cannot be found.please help

Anonymous said...

Hey Peeps. I found that adding TWO hyphens in the "Comment" tag solved this. ie:

Look at Sue Hernandez's post that uses Ian's as a source (if you can get in)

Peter said...
This comment has been removed by the author.
Peter said...
This comment has been removed by the author.
Peter said...

If you add an extra elment above the "Users" element that looks like this " s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string" " you will retain the groupName in the queryfields and be able to query for a group.

Rettajm said...

How do I do this for multiple buttons used for different views within the same form.

Rettajm said...

How do I do this form multiple buttons on the same form?

timothy dempsey said...
This comment has been removed by the author.