locked
Multiple User Roles in InfoPath RRS feed

  • Question

  • Hi there,

    is there any possibilty that one user have multiple user roles in InfoPath?

    Normally, InfoPath reads the Roles from top to bottom and applies the first matching role. But I need to have multiple roles for one user....

    Any solutions?

    Tuesday, August 14, 2012 12:20 PM

All replies

  • Maybe some possible solutions with C#-Code in background?
    Thursday, September 13, 2012 8:15 AM
  • hi,

    it`s possible but InfoPath can read only first role :(

    solution is to write your Roles logic in C#/VB

    Thursday, September 13, 2012 11:39 AM
  • Are there any code examples how to do this?
    Thursday, September 13, 2012 12:06 PM
  • I implement this logic based on our requirements: Role + Document Status. For each status of document only users from one role can approve/reject document. Roles was saved in Fields tree (InfoPath), Type: Group. In each group is a repeater User field. In user field save only userId(eq.: domain\user) of a user. After that write your Roles class who read thease accountId`s and hide / unhide the buttons or edit fields based on current UserId role
    Thursday, September 13, 2012 12:17 PM
  • Should work, thank you
    Thursday, September 13, 2012 12:57 PM
  • I have two more questions:

    1. How can I access the current user in the form through code?

    2. How can I set sections visible/invisible through code?

    Friday, September 14, 2012 6:49 AM
  • 1. How can I access the current user in the form through code?

    You can use the "GetUserProfileByName" dataconnection. Use this to populate a hidden current user field in the form, make sure to clear the field through some sort of submit option  or rule

    2. How can I set sections visible/invisible through code?

    Have no idea :(

    If you need specific instructions on GetUserProfileByName let me know and I'll email them to you or something.


    Thursday, December 20, 2012 2:22 PM
  • 2. How can I set sections visible/invisible through code?

    You can add a boolean field(MyBoolField). Add in your sections a new Formatter rule: if MyBoolField !=TRUE => Hide this field

    In code just verify MyBoolField value.

    Friday, December 28, 2012 2:05 PM
  • In SharePoint, I set up lists of approvers. I have one list for primary approvers, and a second list for secondary approvers. You could do the same thing for roles.

    When the form loads,

    1. set the current user (http://www.infopathblog.com/2012/12/18/setting-the-current-user-in-microsoft-infopath-forms/)
    2. check if current user = primary approver, or secondary approver
    3. hide/display form controls and fields, or switch views based on the current user's role
    Wednesday, January 2, 2013 3:55 PM