Getting all current user’s SharePoint permissions groups in InfoPath 2010

Getting all current user’s SharePoint permissions groups in InfoPath 2010

I followed this great post by Jaliya Udagedara on how to get a current user SharePoint group name in InfoPath, but I needed something a bit different, first of all I was working with an InfoPath form library and not a customized SharePoint list form, secondly I had a scenario where I wanted to show or hide different sections of my InfoPath form to different users according to their permission group, while it’s possible that they belong to several groups. Getting all current user’s SharePoint permissions groups in InfoPath 2010:
The basic idea was that I published my InfoPath form as a content type and added this content type to several libraries, than I’d modified my form to include submit data connections to each library.
Afterwards I’d added several buttons each of them submitting the form to a different library, each button is visible only to users belonging to the corresponding library’s permissions group, or to administrative users that are able to choose the library they wish to submit the form to.


So in order to get all of the current’s user permission groups in an InfoPath text field, follow Jaliya’s post up until step 5 (not including).
Then go to Data -> Form Load and create these 2 actions:

Add 2 Form Load actions

Add 2 Form Load actions

1. Set a field’s value: set the ‘userLoginName’ field on the GetGroupCollectionFromUser data connection (make sure you update this field under the connection’s queryFields group and not under the dataFields group where there is a field with the same name), set its value with the value returned by the GetUserProfileByName connection where – Filter (Name = “AccountName”).

Set a field's value: set the 'userLoginName'

Set a field’s value: set the ‘userLoginName’

Filter GetUserProfileByName Value

Filter GetUserProfileByName Value

2. Query for data the GetGroupCollectionFromUser data connection.

Query Data Connection

Query Data Connection

Create a new text field (I’ve named it CurrentUserPermissionGroups but you can name it anything you’d like), set its default value to contain this formula –
eval(eval(Group, ‘concat(@Name, “;”)’), “..”)

You can copy and paste this formula in to your text field’s default value formula, and then just re-select your group from your GetGroupCollectionFromUser data connection like so –

Update group from GetGroupCollectionFromUser in Formula

Update group from GetGroupCollectionFromUser in Formula

That’s all! Now your field should show all of the current user permission groups (under the site collection of your data connections) –

All the current user's permission groups in InfoPath result

All the current user’s permission groups in InfoPath result

To hide or show fields simply add formatting rules checking if this field contains the group in question –

Formatting Rule Example

Formatting Rule Example

Enjoy!

Sort SharePoint lookup column Dropdown by customizing your list form with InfoPath

Sort SharePoint lookup column Dropdown customizing list form InfoPath

This is a quick solution to a very common issue in SharePoint:

When we create a lookup column in a SharePoint list it is automatically sorted by the alphabetic values of our lookup column in ascending order, regardless of the items id or their created date, and we don’t have an out of the box choice in this matter.


The solution – simply modify your list form with InfoPath, its quick and easy, and here how:

  1. I’ve created a lookup column to a list of fruits, and here’s how my lookup dropdown looks (as you can see it is sorted alphabetically in ascending order):
lookup column sorted by id

lookup column sorted by id

  1. So first thing first I’ll add an order column for my Fruits list and I’ll set their order values by their sizes (more or less..)
lookup list items

lookup list items

  1. Now I’ll go back to my Orders list and customize it’s form using InfoPath:
Customize with InfoPath ribbon button

Customize with InfoPath ribbon button

  1. In InfoPath go to the Data tab on the ribbon and then click on the Data Connections button:
InfoPath dataconnections button

InfoPath dataconnections button

  1. You should now see that your form has already 2 data connections – a main data connection and a secondary data connection to your lookup list:
Data Connection window

Data Connection window

  1. Now simply add a new data connection to your lookup list, clicking on the “Add..” button will open this window:
Create a new Data Connection

Create a new Data Connection

  1. We need the default option of “Create a new connection to: Receive Data” so simply click next, and on the next window chose to receive your data from a SharePoint library or list and click next:
Data connection wizard

Data connection wizard

  1. The next window should automatically show your site’s address so simply click next:
Data Connection wizard screen

Data Connection wizard screen

  1. Now Choose your lookup list from the list of lists under your site and click (Although you already have a data connection to this list on your form we can’t modify it, so we need to create a new one and then we can control it’s sorting)  –
Connection to list

Connection to list

  1. This is the important part, check the checkbox next to the column you need to show in your lookup combo box (In my example it’s the Title column) and also check the one next to your “Order” column, then in the drop down at the bottom of this window choose to “Sort By:” the Order column, and choose the sort order to be ascending or descending according to your need:
Choose columns

Choose columns

  1. Now click Next -> Next -> Finish, If you’d like you can change the name of your new data connection before clicking the finish button, on the last screen of the adding data connection wizard.
Data connection wizard finish screen

Data connection wizard finish screen

  1. Now go to lookup Combo Box on your form, right click it and choose “Drop-Down List Properties” from the bottom of your field menu:
Dropdown list box properties

Dropdown list box properties

  1. Now replace your dropdown list data source to the new data connection you’ve created –
Change datasource

Change datasource

  1. Change your value column to “ID” –
Change value column

Change value column

 15. Click OK –

  1. Now just publish your form, first save it on your computer and then click on file -> publish -> SharePoint List
Publish your form

Publish your form

  1. That’s it! Now your lookup dropdown will be sorted by your order column –
Now its sorted

Now its sorted