How can I make a button visible to specified users/hide from unauthorized users? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How can I make a button visible to specified users/hide from unauthorized users?

Last post 03-22-2018 05:19 PM by jenielle. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 03-21-2018 02:23 PM

    How can I make a button visible to specified users/hide from unauthorized users?

    Hello, I am trying to create a section on my form that is only visible to authorized users. I have already created a "Current User" field which detects the name of the person completing the form (in SharePoint online), and I want to create a rule such that if the user is not one of a specified group of users, the section would be hidden. I've tried creating the following rule and switching it around a couple ways, with no luck: Approach 1: Created one field, Current user and created rule on section, "If Current User does not contain) Name 1, then hide this section." -- That test worked However, when I tried to expand on that rule's condition to include additional users, it didn't work. Here's what I did for that one: Approach 2: "If Current User does not contain) Name 1 or Name 2 or Name 3 or Name 4 or Name 5 then hide this section." -- This did not work I then tried a third approach wherein I created another field called "Authorized Users" (text box field) wherein I entered the user names of each individual, separated by a semicolon (ie Name1; Name2; Name3; etc...) I then created a rule called AuthenticateUser as follows: "If Authorized Users does not contain and I entered one username (as text), then hide this control. -- This did not seem to work either. Can someone please tell me how, or better yet, if what I trying to achieve can be done, and if so, how? Thank you SO much! Jen
  • 03-21-2018 02:29 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    Your approach for does not contain was close... but I think you wanted "and" instead of "or". So, "if current user does not contain John AND current user does not contain Ann AND current user does not contain Bill, hide this control" - kind of goofy but I often have to write out logic in plain English in order to implement it correctly. :)
    Hilary Stoupa

  • 03-21-2018 02:37 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    Hi Hilary! Thank you for getting back to me so quickly. I am new to InfoPath and this logic and conditions stuff is not a strong point for me. I made your suggested change and it worked! You are AMAZING! However I still have a minor issue. The condition is limited to 5 lines, and I have 8 users that are authorized users. I thought maybe I could copy that rule and for the second one, update the three lines with the additional names, and now it isn't working again. What do you do when you have more than 5 lines? Should I take a different approach? Thank you, Thank you, Thank you again! Jen
  • 03-21-2018 03:15 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    I think what makes it hard for me is that the conditions are for hiding, not showing... add in a "not" and my brain sort of blows up. That's why I end up writing it out story problem style. Glad this fixed it! For more than five lines you have a couple options - you could add a second condition with the additional names (and a third and so on). Or, if you set up your conditions and change the first dropdown in one of them to "the expression" you can see the actual XPath, and copy that out into a text editor. You can then build up a single expression with all of your conditions (using "and") and paste that back in.
    Hilary Stoupa

  • 03-21-2018 03:28 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    Hi Hilary, Thanks for your suggestion. I am not familiar/comfortable with expressions at all. But I can show you what I did try (1st attachment - "Rule 1 (5 lines)." That worked great - thanks again! So I thought I could copy/paste that rule and update the text/names in the first three lines, and delete the two additional lines not needed (essentially, Rule 2 (3 lines)), but then none of them worked. But is that basically what you meant when you said add a second condition with the additional names, or did I totally misunderstand and screw this up? The expression idea crossed my mind, but I know nothing about writing expressions. :(
  • 03-21-2018 03:34 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    That was what I meant, yeah. You may have to take the expression approach. It isn't as bad as it sounds. Here's a screenshot that may help. If you get stuck, attach your form under the options tab to a reply and I'll give you a hand.
    Hilary Stoupa

  • 03-22-2018 04:19 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    Hi Hilary, First off, let me say - HAT'S OFF TO YOU! I don't know HOW in the world you make the time to help so many people such as myself, but I want to sincerely THANK YOU for your help - and willingness to do so! I would NOT be able to pull this off without you. Second, I don't know HOW or WHY, but I did not receive a notification as I normally do, alerting me that you responded. So I actually spent a great deal of time today researching expressions to better understand your instruction from yesterday, and I am pleased to say that I successfully created the expression and it worked! I am super excited and proud of myself - cause that was actually pretty sophisticated for me and way outside my comfort zone. But nonetheless, THANK YOU for the detailed response and samples. You are a HUGE help! Enjoy the rest of your evening. Jen
  • 03-22-2018 04:28 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    I'm so happy you were able to implement this! Now you are no longer stuck with just 5 conditions - you can also build more complex conditions as you start to get more familiar. You may want to look into XPath and XPath filters - once you are a little more comfortable with it, a lot of things get easier. I've used InfoPath for teaching myself some of it - creating conditions, then changing the first dropdown to "the expression" and seeing what the XPath is, or selecting "Edit XPath" in the function editor. Here is one of my favorite sites that has good visual examples as well: http://zvon.org/xxl/XPathTutorial/Output/examples.html
    Hilary Stoupa

  • 03-22-2018 05:19 PM In reply to

    Re: How can I make a button visible to specified users/hide from unauthorized users?

    Hilary, this is an awesome resource! I've book marked it so I can learn more :) Thanks again! -- I'm going to jump back over to trying to fix those conflicting number fields. I'm sure we'll talk soon. Enjoy your evening!
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.