Posts RSS Comments RSS 16 Posts and 26 Comments till now

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.


<?xml version="1.0"?>
<s:schema elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
	<s:import namespace="http://www.w3.org/2001/XMLSchema"></s:import>
	<!-- Beginning of insert -->
	<s:complexType name="GetUserCollectionFromGroupType">
		<s:sequence>
			<s:element minOccurs="0" maxOccurs="1" name="Users">
				<s:complexType>
					<s:sequence>
						<s:element maxOccurs="unbounded" name="User" >
							<s:complexType>
								<s:attribute name="Notes" type="s:string"></s:attribute>
								<s:attribute name="Name" type="s:string"></s:attribute>
								<s:attribute name="IsSiteAdmin" type="s:string"></s:attribute>
								<s:attribute name="Sid" type="s:string"></s:attribute>
								<s:attribute name="ID" type="s:string"></s:attribute>
								<s:attribute name="LoginName" type="s:string"></s:attribute>
								<s:attribute name="Email" type="s:string"></s:attribute>
								<s:attribute name="IsDomainGroup" type="s:string"></s:attribute>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>
		</s:sequence>
	</s:complexType>
	<!-- End of Insert -->
	<s:element name="GetUserCollectionFromSite">
		<s:complexType></s:complexType>
	</s:element>

We need to change another part of this file, replacing a s:element block.


<!--<s:element name="GetUserCollectionFromGroup">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
    </s:sequence>
  </s:complexType>
</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.

14 Responses to “Using Sharepoint UserGroup Web Service with InfoPath Forms Service”

  1. on 12 Oct 2008 at 2:44 pmBananaman

    Great post – I’ve been looking round for a no-code method of achiving this.
    I have it all working now – following your insructions.
    Thanks for making this available to all

  2. on 16 Oct 2008 at 11:53 pmcewe

    Hi Ian,
    I tried to use “GetUserCollectionFromGroup” but it gave me an error message of “Infopath was unable to create a schema from the results of the Web service call” and when i clicked on show details, it gives the following message:

    The SOAP response indicates that an error occurred on the server:

    Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.
    The parameter name cannot be empty or bigger than 255 characters.0×80131600

    Do you know why is this happened?

    Thank you
    cewe

  3. on 21 Nov 2008 at 9:40 pmjacob

    I ran into that problem too, cewe. The trick is that you have to enter a group name on the sample data page. In my case it was the GetGroupCollectionfromUser method, and I had to put the domain in front of the username before it would take it.

    Hope that helps.

  4. on 23 Dec 2008 at 5:22 amMathi

    Stitch in time!

    Thanks a lot. Exactly what I wanted.

  5. [...] form and…. Hi, Can you verify below links to get the user name from Sharepoint User Groups. http://blog.ianchivers.com/wordpress/?p=37 http://blogs.vbcity.com/skullcrusher/articles/7734.aspx — Anuma Reddy/ http://www.GGKTech.com [...]

  6. on 22 Jan 2009 at 3:40 amBismarck

    Great Article… Now, how can I remove or hide the “System Account” name that show up in the Drop Down?

  7. on 22 Jan 2009 at 6:06 pmadmin

    Could you setup another group in Sharepoint with just the names that you wanted and connect to that group, rather than the one that contains the “System Account”.

  8. on 23 Jan 2009 at 4:14 amBismarck

    Yep, that will work, thanks.

  9. on 28 Jan 2009 at 7:18 pmRich

    Hi Ian,

    I have looked at so many blogs and have desperately tried to get this working but to no avail. I have followed your instructions to the absolute letter, but when I try to design the form from the manifest.xsf, I just get the error:

    The XML schema specified in the form definition (.xsf) file for dataObject “HR Advisors” cannot be used.

    I’m really tearing my hair out over this – would be really grateful if you can suggest anything to try.

    TIA,

    Rich.

  10. on 30 Jan 2009 at 10:27 amSophie

    Great Post!

    Saved my day :)

    Thanks a lot for sharing this

  11. on 14 May 2009 at 6:54 pmdvallen357

    I’d like to add the user’s phone number in the attributes, I tried
    and
    .
    Neither one brings in the phone number. Anyone know what will?
    TIA,
    Dave

  12. on 03 Jul 2009 at 9:19 amtony_bracjun

    This post helped me a lot. For those looking for MOSS 2007 info and details on definitions of other web servises, please see this> http://download.microsoft.com/download/8/5/8/858F2155-D48D-4C68-9205-29460FD7698F/MS-UGS.PDF

    Thank you.

    Tony

  13. on 30 Jun 2010 at 2:11 pmbnem

    how do I make all of the values and display names lowercase? I’m tried using the translate function but that only makes the first value/display name lowercase.

  14. on 01 Jul 2010 at 3:46 pmadmin

    Good question, I’m not sure how you could do this. Only thought is if there is a data bound event that fires, like in .NET gridview for example – but I seriously doubt something like that would exist in InfoPath. Is there anything you could do if you tell Infopath to fetch the data when the form opens, I think that is an option ? Maybe you could try the Infopath forums to see if there is a way.

    Sorry I couldn’t help!
    Ian.

Trackback this post | Feed on Comments to this post

Leave a Reply

You must be logged in to post a comment.