I am Using Infopath 2013 + SharePoint 2016. How can I hide a field in my form based on user group?
Any ideas? thanks
You can hide fields based on the SharePoint group membership in the InfoPath form. Check if the current user is a member of a group, then hide fields if the current user is not in the group.
In the form, use GetUserProfileByName (SOAP Web service: http://contoso.com/_vti_bin/UserProfileService.asmx) and GetUserCollectionFromGroup (SOAP Web service: http://contoso.com/_vti_bin/UserGroup.asmx) methods to check if the current user is in the specific group. If the current user is not a member of the “Hub Group” group, hide sections which the user has not access.
A demo about how to check if a user is a member of a SharePoint group in InfoPath:
An blog about how to use InfoPath data connection to build rules for hiding/disabling fields based on the SharePoint group membership of current user. Though the links are for InfoPath 2010, but should still have some good information.
Follow below steps:
Get Current user Login name using InfoPath fields and store it in a first hidden field.
Use REST API to query all current user groups.
Concat all group names and store them in a hidden field in the form.
Then you will be able to create a rule to test if target group exist in the Hidden Field Value.
This took me 1 week to configure last year, Unfortunally, I dont have anymore access to the customer server. Sorry for that.
There is a SOAP Method that doesn't worked for me at that time because of a bug or incompatibility beetween SharePoint 2016 and InfoPath Designer 2013.
If you are using SP 2013 or 2010 please refer to this link.
Let me know if this was helpful for you.