Switching View only works once - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Switching View only works once

Last post 11-26-2006 02:52 PM by Soham Bhatt. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 11-09-2006 08:42 PM

    Switching View only works once

    i'm creating a new request form with 3 views (Request, Approve, Denied) where a user fills in the required information and submits to the line manager (Request view). Line manager have a different view (Approve) which he can approve or decline the form. On approving it sends and email out to the designated person inchange of providing the service. All works fine till here. But the next step is where if a line manager declines - it sends an email back to the user to submitted the form with the Denied view or Request view (both having the same submit button). For this case it doesnt swtich the view.

    I'm currently switching the views in Tools -> Form Options -> Open and save
    Soham Bhatt
  • 11-09-2006 10:07 PM In reply to

    • Mahitha
    • Top 200 Contributor
    • Joined on 05-24-2005
    • India
    • Posts 57

    Re: Switching View only works once

    Instead of this you can use rules on each and every button.
    Button Properties-->Rules-->Add-->Add Action-->Switch views

    Hope this Helps.
  • 11-09-2006 10:11 PM In reply to

    Re: Switching View only works once

    If you do it from Button Properties then it changes the View then and there - But a normal user shouldnt have that authority to change the views. The data gets submitted to user a Data Connection (emailing to the Line Manager). And when Line Manager opens the Form the view is changed to Approve.
    Soham Bhatt
  • 11-09-2006 10:34 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Switching View only works once

    Hi Soham Bhatt,

    You can write code for button to switching to another view.

    btnSwitchView_OnClick(DocActionEvent e)
    {
    String viewName = thisXDocument.View.Name;
    if(viewName == “Request”)
    {
    SwitchView(“Approve”);
    }
    else If(viewName == “Approve”)
    {
    SwitchView(“Request”);
    }
    else If(viewName == “Denied”)
    {
    SwitchView(“Request”);
    }
    }
    private void SwitchView(string viewName)
    {
    if(thisXDocument.View != null)
    thisXDocument.View.SwitchView(viewName);
    else
    thisXDocument.ViewInfos[viewName].IsDefault =true;
    }

    By using above code you can switch view where do you want and when do you want to switch the view depends on your condition. As per your requirement you can change the condition.

    Note: Above code in C#.
  • 11-12-2006 07:26 PM In reply to

    Re: Switching View only works once

    Thanks Shiva - but i want the solution using rules. Seems that if i make the new form with the same concept then all works fine. May the old form had something in it from stopping it to switch from Approve to Deny.
    Soham Bhatt
  • 11-14-2006 10:40 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Switching View only works once

    Hi Soham Bhatt,

    That works too! Glad to hear you got it working for new form.
    Can you check once your Rule condition is correct or not. One more are you need to check view name is exact match to “Deny” view name.
    Can you try to put same Rule one more time to old form then it works or not.
  • 11-23-2006 07:31 PM In reply to

    Re: Switching View only works once

    I figured out the problem associated for not switching to the last view.

    1. When a button was clicked in any view it makes the "view" condition True.

    for example: If i'm submitting the form - on click i make the value of submit to true. for Approve - approve is true, etc

    2. On Form Options (Open and Save) i was checking if the value of submit is true and it wil swtcih the view (all good at this point) but this will work only one time and if the form is denied and re-submitted - it wasnt applying the rules properly and showing teh correct view. This is because all teh condition is checked and all the values (Submit, approve,deny) is true.

    Solultion: I just had to make everything else false on the above options and then swtcih the view.

    It now loops as many times as required.

    Thanks you all for your inputs
    Soham Bhatt
  • 11-24-2006 08:09 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Switching View only works once

    Hi Soham Bhatt,

    Glad to hear you figured it out and thanks for posting your answer here.
  • 11-24-2006 12:16 PM In reply to

    Re: Switching View only works once

    Hi Soham,
    Instead of maintaining three fields for each state, you should have one field which contains the state of the form and you can switch the view based on the this variable. This will reduce the size of the XML(even though very small but good practice) and no confusion when using the field.
  • 11-26-2006 02:52 PM In reply to

    Re: Switching View only works once

    Agni - could you explain more on it please (if possible with an example). Thanks
    Soham Bhatt
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.