Show/hide fields based off User Group/Role in Sharepoint? RRS feed

  • Question

  • I've looked everywhere for this, and can't find a single working answer. I am building a form in infopath that will be used on Sharepoint as a Browser-based form. This is a requirement that I cannot avoid.

    I'd like to be able to hide fields/controls or at least show a different view based on the sharepoint user role/group of the person reading the document. How can I do this, but still keep the form browser-based? Even if it's a roundabout way, I need to figure out how to do this.

    Any ideas?
    Wednesday, January 16, 2008 7:52 PM


All replies

  • Well.. it ain't pretty, but here is what I did.


    Create a custom list in Sharepoint. Call it "Approvers". Change the name of the Title field to Login. Create a new column called Person and make it a Person / Group field (but only allow selection of a person).


    Add a few people from the people picker. Pick them and put them in the Person field, but in the Login field, you must type thier login id. So John Doe would mostly likely be jdoe. Put jdoe in the Login field (don't put in the domain).


    Then, go into InfoPath 2007. Create a data connection that will receive data from that sharepoint list (its one of the options available).


    That data connection will be filled with a list of names from that Sharepoint list. So you could set up a conditional formatting where UserName() is in that datasource.


    It doesn't use Sharepoint groups, but it does give the end user the ability to add/remove people and give permissions inside of the form.


    Hope that helps and if anyone has a better way, I'd love to hear it...


    Thursday, January 17, 2008 6:52 AM
  • Thanks for the response. It certainly is not pretty, but I appreciate it. However, I'm having problems getting it to work. I created everything as you said, made the data connection, but nothing that I set a condition to seems to happen, even though I know my username is in that list. I tried using the condition:
    "Approvers" contains "userName()", "Login" contains "userName()", and just for completeness, "Person" contains "userName()", to no avail. Is there a different way to write that condition so that works?
    Thursday, January 17, 2008 3:15 PM
  • userName() doesn't necessarily match up to "person or group".  You're probaby very close.


    The notes in this blog entry might help you: http://feeds.feedburner.com/~r/PaulGalvinsSharepointSpace/~3/215544577/cns!1CC1EDB3DAA9B8AA!623.entry


    BTW, be careful with the title column's label.  Doing that has greater consequences than you might think.  It may be OK for a column added to a list, but not ok for site column.


    --Paul Galvin, Conchango
      RSS @ http://feeds.feedburner.com/PaulGalvinsSharepointSpace
      Web site @ http://paulgalvin.spaces.live.com


    Thursday, January 17, 2008 9:29 PM
  • Just so you can see what is being returned, try this.


    Create a node in Infopath.. call it "field1". It doesn't matter the name.


    Then drag onto the form. Do a right click on it and change it to a combo drop down box.


    Then, select the "List Form Entries" to come from "Lookup Entries from an external data source".


    Select one of yoru new data sources in the drop down box.


    Then, on the Entries, click the little box to the right and select the folder icon that is just above the data elements. The two data elements that will be shown are Login and Person. but select the folder above that.


    Then, you can tell the combo box what element to display and what element to store. For now, set both of them to Login. Later, change the Display Name to Person.


    Then preview the form.


    The choices in the drop down box should be the items from the list and you can see what is being returned.


    Thursday, January 17, 2008 10:43 PM
  • Thanks! That did it! Got it to work now. It didn't work with a "contains" statement, but it works with "equals", so that's all I need!
    Friday, January 18, 2008 6:06 PM
  • Eitan, this thread is over 2 years old.  Your description of that tool does not seem related to the question of incorporating user roles into browser forms.  How is it related?

    Since I'm answering, here are my solutions that all work in browser forms:

    1. Use a Contact List: InfoPath – User Roles in Browser-Enabled Forms Using Contacts List
    2. Use AD groups (distribution lists or security groups): InfoPath - User Roles in Browser-Enabled Forms Using AD Groups
    3. Use SharePoint Groups (more difficult than #1 and #2): Using Sharepoint UserGroup Web Service with InfoPath Forms Service

    SharePoint Architect || Microsoft MVP || My Blog
    • Marked as answer by Clayton Cobb Thursday, June 16, 2011 4:33 AM
    Friday, June 18, 2010 5:31 PM
  • It's OK Clayton.

    I've deleted that post. Mr. Bach is a spammer. Every post he makes recommends a product from the same company. Any guesses as to which company he works for or owns ?

    (Hence his posting to an ancient thread).

    Mike (Moderator)

    2010 Books: SPF 2010; SPS 2010; SPD 2010; InfoPath 2010; Workflow etc.
    2007 Books: WSS 3.0; MOSS 2007; SPD 2007; InfoPath 2007; PerformancePoint; SSRS; Workflow
    Both lists also include books in French; German; Spanish with even more languages in the 2007 list.
    Sunday, June 20, 2010 1:40 PM
  • Hi Clayton

    Any idea how to do choice 3?

    any article would help greatly.



    • Edited by Clayton Cobb Thursday, June 16, 2011 4:33 AM Removed excessive white space
    Wednesday, June 15, 2011 3:46 PM
  • Hi Matt,

    The original link Clayton posted has become outdated; here is the current link:



    • Marked as answer by Clayton Cobb Thursday, June 16, 2011 4:33 AM
    Wednesday, June 15, 2011 4:38 PM
  • Yeah, the blog I linked was moved to a different link on the same blog.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Thursday, June 16, 2011 4:33 AM
  • Maybe you'll prefer to use SharePoint Forms Designer instead of Infopath, it provides easy to understand drag&drop browser interface even for business user. You can create different forms for specific SharePoint groups.
    Friday, January 11, 2013 9:21 PM