Switching views based on username() not working - InfoPath Dev
in

InfoPath Dev

Switching views based on username() not working

Last post 09-22-2015 11:16 AM by patchoo. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 09-17-2015 11:46 AM

    Switching views based on username() not working

    Hi Everyone,

    I joined this board because I've seen a lot of good tutorials and tips here that have helped me overcome some obstacles when I build my forms, however, I am stumped on this one issue so I am a first time poster.

    SCENARIO:

    A user submits an infopath browser filled form. The form gets submitted into our form library. We have about 10 various forms that are all stored as content types. This user can only see requests they have submitted because I used the [ME] filter and blocked user abilities to change their view. However, our team needs to be able to see all requests (forms) and action them, so i created personal views on each of their workstations without the [ME] filter, allowing them to see all requests we work on. As an alternative, and to simplify things, I'd like to have the form filter out who can see the contents of the form, because then we can just open up the view a bit and only have the default public view without the hassle of personal views, etc etc (there's many more reasons why we would switch).

    I implemented a controls page - a hidden page where users filling out the form are unable to see. This controls page has a few fields such as SUBMITTING USER and VIEWING USER. On FORM LOAD, the form sets both of these fields to what the username() should be. I originally used a combination of substring and username() to provide the login id of the person into those 2 fields, but it didn't work, so I changed it to FORM LOAD rules and it worked. So......if I submit a form, it shows my username in SUBMITTING USER and VIEWING USER. If I submit a form and a colleague opens the request to action it, SUBMITTING USER shows my login id but VIEWING USER shows his or hers - OK!

    I have rules setup where "if viewing user is NOT equal to the submitting user, show access denied page". The access denied page is a 3rd page I setup in the form itself, and if the viewer and submitter are not the same, it shows them the access denied page.,

     Here's where the problem is..............as a team of 7, and max conditions of 5, how do I go about adding the fact that not only is the original submitter allowed to see the request and open it, so is the 7 people on the team.

    After the FORM LOAD rule of the comparison for viewing user and submitting user, there are only 4 condition slots left. Some people say use the last one as code, however, its not a matter of that. Right now, I have set 2 conditions, the original user comparison, then the 2nd one is to compare the viewing user to a list of names (the list of names from my team) to see if they're on there, and if so, let the person view the list (to action the request).

    I tried reding from both a sharepoint list with team names in a dropdown menu, as well as just saying "forget it, lets do it the nonsense way" and adding names straight to the rules.

    PROBLEM: Using just 1 team members login id has an example, trying to open a form submitted by another person, instead of opening up and being readable for actioning by our team, we also get blocked out.

    Someone submits the form, we go to open it, we get access denied.

  • 09-17-2015 04:25 PM In reply to

    Re: Switching views based on username() not working

    Hello patchoo,

    It may just be a matter of switching your logic around. The field that stores the "Submitting User" should only change if the field is blank. This means, it would only happen with the first form open. Then the "Viewing User" should change every time the form is opened.

    After that is evaluated your rule to switch views on form load should be:

    If "Submitting User" != "Viewing User" switch to view access denied.

    Hope that helps,

    Bre

  • 09-18-2015 10:12 AM In reply to

    Re: Switching views based on username() not working

    Hi Bre, Thank you for your reply. Actually, my condition of "Submitting User" != "Viewing User" works just fine. My problem becomes when I need to evaluate the fact that the viewing user of the form is not the original submitter.... AND... The viewing user is not a member of our work team. In essence, when someone submits a request, the only people who should be able to open it are: 1) the original submitter 2) one of the 10 team members No matter what type of coding I do with AND/OR, all of the team members get ACCESS DENIED (the 3rd page in my form). It could also be the way I have the teammembers listed...I have a dropdown list in the controls page (2nd page) and all teammembers are listed in this dropdown. Since that didn't work, I started testing using the login ID of 1 or 2 teammembers and used the equation to evaluate text (their login ID in text format instead of the drop down)....can't seem to get it. :(
  • 09-18-2015 02:47 PM In reply to

    Re: Switching views based on username() not working

    Hello patchoo,

    Here's an example form. Publish this out to a test location, and take a look at the rules on Form Load. It could also be the sequence of your for, but this should work for anyone who is not the original form creator.

    Best,

    Bre

  • 09-22-2015 07:52 AM In reply to

    Re: Switching views based on username() not working

    Hi Bre, I thank you for trying to help, but again, the document you've attached and the explanation above is already working - the comparison between viewing user and submitting user already works. I need to get the 2nd part working - here's the logic I'm looking for if it helps STEP 1: Set SUBMITTINGUSER to the ID of who submitted the request (works) STEP 2: Set VIEWINGUSER to the ID of who is viewing the request (works) STEP 3: Compare both the above fields - If the viewing user is NOT the submitting user, proceed to step 4. STEP 4: If "TEAMMEMBERS" does not contain VIEWINGUSER, ACCESS DENIED You see? I hope I have explained it properly. We need to compare to 2 fields before access denied. In plain words, the only people who open the request and are actually able to see the details are: 1) the original submitter and 2) any member on the operations team (10 team members). If neither #1 or #2, any other user would get access denied. Please assist. Thank you *EDITED* Forgot to mention that I've created various types of fields such as dropdowns, textboxes, etc etc to hold the information of teammembers, but not sure what type of field it should be.
  • 09-22-2015 08:39 AM In reply to

    Re: Switching views based on username() not working

    Hello patchoo,

    Sorry for my misinterpretation. For this part you may want to use an external list on SharePoint, as the users that should have access may change. I would use a people picker column in the list, and add an entry for each user. Then in your form, create a data connection to the lit and query on load. You'll then want to run the switch view action if any occurrence of AccountId from the secondary data source is not equal to the VIEWINGUSER.

    If you want to go with your current method, change the conditions to the expression, ad paste into notepad or another text editor. Here you can add as many conditions as are needed, and paste back into the expression box to allow for more than 5 conditions on a single rule.

    Hope that helps!
    Bre

  • 09-22-2015 11:16 AM In reply to

    Re: Switching views based on username() not working

    Hi Bre, I'm a little bit confused, I'm terribly sorry. I also thought it'd be best to have the forms load content from a sharepoint list, so changing that column (ie. "TeamMembers") can be updated at any time, and all 11 or so forms would pull current information, rather than going into each form and republishing everytime a chance occured. However, I tried this and can't get the form to read anything from the sharepoint list NOR can I get the form to validate the expression using a drop down list within the form itself. Right now I don't know if its a logical expression error or if reading the list of names from various sources is the problem. I can't follow along with your recommendation, I'm sorry, because i don't understand. I know there are maximum 5 conditions and you use the expression function to generate the syntax but still, nothing is working. My current conditions are as follows (for the comparison and subsequent redirection to access denied):
    Run the rule with this condition is true: VIEWINGUSER is not equal to ORIGINALSUBMITTER and APPROVEDVIEWERS does not contain VIEWINGUSER
    (approvedviewers has been set to a dropdown list AS WELL AS a list in sharepoint, neither work) I don't know what you meant by people picker, because when I put a people picker on the form as a field, it has nowhere to advise it to pull data from sharepoint list/columns. Also, my fields being used above all return a LOGINID, not a full name or email, so I need something that can compare the username to the original LOGIN ID
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.