SharePoint Blog

Leave a comment

How To: Check if a user is part of a SharePoint group in web based InfoPath form

I know that there are so many articles about this topic, but many of them were too complicated for many people to understand and most of the available articles only work with Classic authentication and not claims.

I have a group called MYInfopathGroup in which I want to check if the current  user is part of that SharePoint group. Below are the fields to show you  how it look like.


First we need to retrieve the Account Name of the current logged in User. We can retrieve this information by using userprofileservice.asmx, Below are the steps to create the data connection. I am going to write a detailed article about how to retrieve the Account Name.

  • Click on Data Connections under the Data tab and select Add
  • Create a new connection to receive data
  • Select the SOAP Web service option
  • For the location  of the web service type:http://MyServerURL/_vti_bin/UserProfileService.asmx
  • Select the GetUserProfileByName method and click Next
  • Use the default settings in the next screen and click Next again
  • Click Next
  • Use the default settings, click Finish and close the dialog window

Select the properties of the username field from the main source.

  • Now add rules to the form load of the infopath form.
  • We need to add 3 rules.
  • Remove the second double click to insert field and replace it with“ABCDEFGHIJKLMNOPQRSTUVWXYZ” (incl. the quotiation marks)
  • Remove the third double click to insert field and replace it with “abcdefghijklmnopqrstuvwxyz”(incl. the quotiation marks)
  • The function should now look as follows:
    translate(double click to insert field; “ABCDEFGHIJKLMNOPQRSTUVWXYZ”; “abcdefghijklmnopqrstuvwxyz”)
  • For the first parameter double click on double click to insert field
  • From the drop down select the GetUserProfileByName data source
  • Expand the dataFields group as shown in the screenshot and select Value


Select the filter data and the filter should look like this.


At this stage the form queries the current user’s account name and stores it in the username field on form open. The forms runs fine on the InfoPath client but when we use the same form in the browser we get Access denied.

To over come this issue you need to Convert the data connection to Udcx file. We can achieve this by just clicking on the Convert to Connection file button available on the Data Connections.

Go to the data connection library and open the file in notepad and uncomment the udc:Authentication tag in the generated data connection udcx file.

Below is the sample tag


<udc:SSO AppId=’InfoPathWebService’ CredentialType=’NTLM’ />


Next we will query the UserGroup web service to get us a list of users in a specific SharePoint group:

  The UserGroup web service contains a method “GetUserCollectionFromGroup” which we will use in our setup:
  • Click on Data Connections under the Data tab and select Add
  • Create a new connection to receive data
  • Select the SOAP Web service option
  • For the location  of the web service type:http://MyServerUrl/_vti_bin/UserGroup.asmx
  • Select the GetUserCollectionFromGroup method and click Next
  • In the next screen select Set Sample Value and provide InfoPath with the name of the group you want to query (e.g. if your user is in a SharePoint group “Test” put in “Test“)
  • Click Next
  • Provide InfoPath with the same group name in the next screen and click Next again
  • Click Next
  • Use the default settings, click Finish and close the dialog window

We need to save our form and then use the Export Source Files option under “Publish“ tab.


Once that is done, close the form and navigate to the location where you exported your form to. Open the file named “GetUserCollectionFromGroup1.xsd“. This file defines the XML schema. Open the file in Notepad++ or Visual Studio

Right under this code within the file:

<s:import namespace=””></s:import>

<s:complexType name="GetUserCollectionFromGroupType">
  <s:element minOccurs="0" maxOccurs="1" name="Users">
     <s:element maxOccurs="unbounded" name="User" >
       <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>

Now locate the following piece of code within your file:

and replace it with this:
<!--<s:element name="GetUserCollectionFromGroup">
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
<s:element name="GetUserCollectionFromGroup" type="tns:GetUserCollectionFromGroupType" />

Now save the file and open the manifest.xsf by right clicking it and select Design.

If you have a look at your GetUserCollectionFromGroup data source and its fields, you will notice that it has changed from this:


Will look like this


Now the last thing we need to do is setup the IsGroupMember field. We want it to return a 1 if the user is in the group and a 0 if the user is not in the group.

  • Right click the IsGroupMember field and select Properties:
    • In the property window select the formula button for the default value
    • Select Insert Function
    • Select the Count function
    • Remove doube click to insert field
    • Within the Count function click Insert Function and add the translate function
    • Remove the second double click to insert field and replace it with“ABCDEFGHIJKLMNOPQRSTUVWXYZ” (incl. the quotation marks)
    • Remove the third double click to insert field and replace it with“abcdefghijklmnopqrstuvwxyz” (incl. the quotation marks)
    • For the first parameter double click on double click to insert field
    • Select the GetUserCollectionFromGroup data source
    • Expand the dataFields group and select “LoginName”
    • Select Filter Data and add a new filter
    • Leave the first drop down as is (It should show “LoginName“)
    • Select “Select a field or group” in the third drop down
    • Select the “Main” data source
    • Select the “CurrentUserAccountName” field
    • Confirm all open windows by clicking on “OK

We are done. You can now use the “IsGroupMember” field to hide and show different sections and fields in your form based on if the user is a member of the configured SharePoint group.

One thing to be aware of though is, that whenever you change the “GetUserCollectionFromGroup” data source, you will need to go through the setup process again for this data source.




This is a guide for setting up an InfoPath form that will fill in other textboxes with data retrieved from a SharePoint list or library, this form will be published to a SharePoint form library in order to provide end users an easy way to fill in a form. This solution is created by using InfoPath 2013 and SharePoint 2013.

Continue reading


Retrieving data from InfoPath repeating tables

Programmatically We can retrive the values from an repeating table in a infopath form, In some cases we might need to retrive the content from an repeating table and save the content to SharePoint list.

Continue reading

Leave a comment

Add SharePoint List Items with InfoPath web form using SharePoint Object Model

You want to save the data that is entered into an InfoPath form to a SharePoint list, but InfoPath does not allow you to submit data to a SharePoint list.

This is one of the  useful feature of Microsoft SharePoint is its ability to create and maintain lists that users can leverage to store, view, and share items with other users of the SharePoint site. It is often desirable to be able to view these items and to add additional items with an InfoPath form.

You can use SharePoint object model to insert an Item to a SharePoint List.

Note: Users must have proper permissions assigned to them to be able to add items to the SharePoint list.

Continue reading

Leave a comment

How to dislay Hand Icon for Buttons on mouse over in Infopath Forms

To display the Hand icon instead of pointer on mouse over of Button in Infopath Form, follow the steps below:

  • Open the Infopath form(InfopathForm.xsn) in design mode.
  • Export  Source files of the Infopath form


  • Go to the Exported Files location and open the xsl file(notice that it will create an xsl file for each view in the Infopath form) in an editor.
  • Search for “type=”button”” and for that button style add “cursor:pointer”. Save the file
  • Open “manifest.xsf” file in design mode from the same location.
  • Publish the manifest.xsf file.


jQueryUI’s Autocomplete Function on InfoPath Forms in SharePoint

Recently I worked on a requirement where I need to implement the functionality of JQuery UI´s Auto Complete functionality on a Text box of Browser Based Infopath forms in SharePoint.

We all are familiar with this idea of AutoComplete, if not the actual term. You probably see it in action every single day as you use a search engine. As you type your search term(s), the search engine shows suggestions, probably based on some fairly sophisticated algorithms.
Continue reading


InfoPath 2013 Web Browser- Creating Cascading Dropdown Fields with no Code

How many times you require functionality where in based on the selection of parent drop down generates the values to the child drop down.

Examples, selection of Continent fills the Countries drop down.

We can achieve this functionality in INFOPATH Web forms without writing a single line of code.
Continue reading