Change Views based on userName() - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Change Views based on userName()

Last post 01-27-2012 08:27 AM by David.Young. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-22-2010 01:37 PM

    Change Views based on userName()

    Hi,
     
    Scenario:
    A user fills out a form from a SharePoint Library and submits the form using InfoPath 2007. (This is not a web forms services form.)
    A SharePoint Workflow sends an email to 5 diffent Managers with a link to the xml file which opens in InfoPath 2007. 
    I need my managers to be sent to their own personalized view to click on a button to approve the form and write their comments, etc.
    Since I have 5 managers, I created 5 views.
     
    Because I plan to create many forms I do not want to update each form whenever a new manager gets hired so I want the form to be dynamic.
    Otherwise I know how easy it would be to add the user names of the managers to user roles and switch the view with an open behavior rule for each.
     
    Here was my plan.
    1.  Create 5 text fields and name them Manager1, Manager2, etc.
    2.  Create a data connection to my SharePoint List which has Job Title and UserName Columns
    3.  Set the default values of the Manger1, etc fields to filter the data connection based on thier job title and store the appropriate username.
    4.  Create an Open Behavior Rule for each Manager like so:   
     
    Apply the Role when the Condition is True:      
    Manager1field contains userName()     (PS..I also tried "equal to" instead of contains)
    Switch to View: Manager 1's View
     
    I ALMOST got this working.
     
    Although I am successfull at setting the correct user name value in the Manger1 field (example: "JSmith") my open behavior rule is not switching the view.  
    I know I am setting the value correctly as I see "Jsmith" in the field when I preview the form.  
     
    But

    When if I set the default value to the manager1 field manually to Jsmith and use the same condition, the view switches perfectly.

    Any idea why InfoPath does not like my value when it is a result from a data connection filter?

    Thanks again for any suggestions you have!!!
  • 09-22-2010 02:51 PM In reply to

    Re: Change Views based on userName()

    Hi:

    I'm not sure if this is a typo -- but I see in your example "JSmith" with a capital "S" -- Your conditions will be case sensitive, so keep that in mind.

    You can use rules with dialog box expressions to help you see why a condition isn't being met. For example, in a rule prior to the rule for switching views, you could show a dialog box expression with the values of all the different "manager" text boxes, see if the values are being set prior to the rules for view switching running.

    Hilary Stoupa

  • 01-27-2012 08:27 AM In reply to

    Re: Change Views based on userName()

    I found that (Seemingly) the case changes - Since it [is] case sensitive, I am translating everything like these to lowercase:

    translate(FName, "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz")

    Then compare fields - switch views accordingly.  Make sure to do this in the proper order - Form Load --> field --> etc (Order matters of course)

     Hope to help,

    David Young

    IT App. Programmer / Analyst II

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.