Search code examples
sharepointinfopath

How do I hide a textbox, if user is not on the SharePoint list?


First of all, I am using Polish version of both InfoPath and Sharepoint, so I am translating all terms myself. I'm sorry for any mistranslations.

As in the title: I have a form, implemented in InfoPath 2013. This form has to be published into SharePoint Form Library.

My problem is, that some of the fields in the form are supposed to be visible only to people with special privilege (HR). List of those people is given as Custom Sharepoint List.

I tried hiding them with conditional formatting by setting that item is hidden if List's Title is not equal to userName() function. However, it seems to not be working.

However, if I set this condition as List Title is equal to userName, the formatting works as expected.

I tried also using Contains and Not contains, and Starts with conditions, with same result. I'm also limited to what can be done directly with Infopath, as I can not use any C# code with this form due to Sharepoints settings.

How can I hide any formants (items) from view, if user viewing them is not on given list?


Solution

  • You can have multiple views in InfoPath forms. Apply the rules to the views based on the current user permission.

    Check THIS out for detailed steps

    EDIT:

    As the link is now broken, you need to add a new connection to the list and select the fields you want to query.

    Then on the "Check existence" you'll add a couple of Action rules. Under when the condition is true go Under Then apply this formatting, click Hide this control and hit OK