switch views - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

switch views

Last post 10-30-2009 06:34 AM by chhaya singh. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 10-23-2009 04:12 PM

    switch views

    Hi,

    I have a form with 2 views, one is a user view and the other is a admin view.

    I have created a text field which imports current user data from Active Directory. Depending upon user name it has to switch view. It is working fine for users when we open the new form. However, if a user submits the request and if admin role user opens the form, it is not going to the admin view.

    I am doing it through Form options, Open behavior Rules..I am setting condition and then switching view.

    How can I achieve the admin view functionality for the forms submitted by the users. Please advise.

    Thanks

  • 10-25-2009 09:53 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Hi,

    Can you try with below steps?

    1.       First set User View as Default view.

    2.       And add open Rule as “Text” field is not equal to “User Group” then switch view to Admin view.

    Let me know still you have any issues.

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 10-25-2009 11:45 PM In reply to

    hi,

    my best guess is that you are not updating the text field in which user data is imported. You have unchecked the option to "Update this value when the result of the formula is recalculated". Check that option in text field properties and it should work.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 10-26-2009 09:27 AM In reply to

    Qazi,

     

    I have that formula 'Update this value when the result of the formula is recalculated" is checked. But still it is not updating the value..

    Please help!

    Thanks

  • 10-26-2009 09:28 AM In reply to

    Anuma,

     I understoood setting the user view as Default view. However, I did not understand your 2nd step. Could you pls explain it to me.

    Thanks for your help

     

  • 10-27-2009 12:47 AM In reply to

    Krishna, I thought you would have set the rules on opening of the form to do so.

    well to set the rule on the opening of the form go to tools-> form options -> open and save-> rules

    add a rule there to switch your view based on the value in the textbox

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 10-27-2009 01:48 AM In reply to

    Hi Krishna,

     did u check whether the text field is getting populated with the username of admin? When u open a new form,it will fetch the usernam that u can select as function in infoapth form.But when u submit the form text field value will have the value of the username of the user.This may be the cause of ur Admin view not showing properly.I had requirements like this before and for that i always prefer to use code.If you are ready to use that.You just need to copy these few lines in form loading event..

    string xpath = "xpath of ur text field";

     XPathNavigator field1 = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
     string strUserName = System.Environment.UserName;
     field1.SetValue(strUserName);

       It will solve ur problem of fetching the current user name..And so for views as well.Let me know if u still encounter any problem.

    Vishal Srivastava
    Senior Software Engineer
    SDG Software Pvt Ltd
  • 10-27-2009 02:25 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525
     Hi,

    Here are the details for second point.

    1.       Go to Tools à form Options.

    2.       Click on Rules button in “Open and Save” tab.

    3.       Click on Add button and click on Set Condition button.

    4.       Select “User Name” field in the first dropdown.

    5.       Select “Is Not Equal To” in the second dropdown.

    6.       Select “User” name or user group from third dropdown. [If you have admin group then select Admin group in this dropdown and select “Is equal to” in second dropdown.]

    7.       Click on ok.

    8.       Click on Add Action Button.

    9.       Select Switch Views from Action Dropdown.

    10.   Select Admin View in second dropdown,

    11.   Click on ok to close all windows.

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 10-27-2009 09:02 AM In reply to

    The text field is populated with the user initiating the form. So, when a user submitting the form, it is taking the current user name(initiator) from AD and saving it. So, When I am opening the form, it is not changing the name. I am switching views depending upon the user name.

     I am ready to use the loading event. However, I don't understand the

    string xpath = "xpath of ur text field"

    I am new to xpath and I am not sure where do I need to get xpath of text field.

    Please let me know.

    Thanks

    Krishna

  • 10-28-2009 02:13 AM In reply to

    hi krishna,

    you will need a data connection to populate the current user name and based on that change the views.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 10-29-2009 07:12 AM In reply to

    You still need to do what everyone said about setting that field using a Form Load rule.  If you use a default value, then it only sets the data once - on initial open.  if you set a form load rule to set that field with the current userName(), then it will always keep track of the current user's identity.  From there, you have to have some way of comparing the current user against some list to know whether or not the person is an admin.  I don't know what you're using for this comparison, but the concept is very simple.

    You should not need a data connection unless your list of admin is a SharePoint list that you need to consume and compare against, or unless you need to use the UserProfileService to compare user profile attributes like group memberships.

  • 10-30-2009 06:34 AM In reply to

    Hi Krishna,

    I agreed to what warrtalon is saying. You need keep two field one in which ur Initiatrot name will be there. And second for current user value. Now you compare the value of both the filed. If Initaitor field value is equal to current user value switch to employee view. If value differs switch to Admin Value.

     

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