Manage Role Based Access in info-path forms RRS feed

  • Question

  • Hello Friends

      I have one info-path form and one view for that form. 

      1) Default

      2) Named view 

      I gave few columns for default view and some other columns for Named view . when ever we edit item it is showing both views on top ribbon. how to control  those views based on user login.

    Friday, April 17, 2015 9:09 PM


  • You can simply hide the Views on the ribbon while you edit the form. Go to File tab > Form Options and uncheck View from the below option and then save/publish your form.

    If you are looking for another approach without touching the above option, then in InfoPath Designer open:

    - Click Data tab
    - Click Form Load button
    - Create a rule that switch views based on the currently login user where condition would be
    CurrentUser == "Venkat Garikapati".
    - You should create a field 'CurrentUser' that will control the view. This could be simple text field.
    (CurrentUser would be a field that fetches the currently login user. You can implement this approach by code-behind where you will fetch the currently login user in store it in CurrentUser field).

    Code-behind logic to fetch currently login user and update it on CurrentUser field:

    public string currentLoginUser
                    string _user = HttpContext.Current.User.Identity.Name;
                    return _user;

    This code will fetch saMAccountName along with the domain name. You should implement a logic to discard "\\" character from the name and fetch the display name from AD.

    root.SelectSingleNode("/my:SalesFields/my:txt_CurrentUser", NamespaceManager).SetValue(userName1);
    Above userName1 is the final display name fetched from AD.

    Please remember to click 'Mark as Answer' if the reply answers your query or 'Upvote' if it helps you.

    Sunday, April 19, 2015 7:30 AM