ViewInfos.SwitchView getting view name from field - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

ViewInfos.SwitchView getting view name from field

Last post 11-21-2012 08:13 AM by Sander0123. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-21-2012 02:24 AM

    ViewInfos.SwitchView getting view name from field

    Using Infopath 2010, browser enabled form on Sharepoint 2010, coding is in VB.

    I created a field called GoToView that get's the name of a view based on a Sharepoint list with a filter based on two drop down boxes. To verify the result I temporary show the content of this field in a text box. This works perfectly.

    I created a button to switch views. I know this can be done with a action rule but I think I cannot pass on the value from GoToView into one of the rules to determine the correct view.

    I've used this code to test the button witch works fine.

      Public Sub CTRL14_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                Me.ViewInfos.SwitchView("PMI")
            End Sub

    My questions is: how can I replace "PMI" with the dynamic content of the GoToView field?

  • 11-21-2012 06:54 AM In reply to

    Re: ViewInfos.SwitchView getting view name from field

    You'll need to get the value from the field - C# would be (with your XPath to your node replacing the bold text, of course):

    string viewName = MainDataSource.CreateNavigator().SelectSingleNode("XPATH TO NODE GOES HERE", NamespaceManager);

    Then you can use the variable in place of "PMI"

    ViewInfos.SwitchView(viewName);

    Hilary Stoupa

  • 11-21-2012 07:26 AM In reply to

    Re: ViewInfos.SwitchView getting view name from field

    Thanks, this will help me in the right direction.

    Unfortunately it is giving me tthis error: Error 1 Cannot implicitly convert type 'System.Xml.XPath.XPathNavigator' to 'string' 

    My code does now looks like this:

    public void CTRL14_5_Clicked(object sender, ClickedEventArgs e)

    {

    string viewName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:GoToView", NamespaceManager);ViewInfos.SwitchView("viewName");

    }

     

     

  • 11-21-2012 07:36 AM In reply to

    Re: ViewInfos.SwitchView getting view name from field

    That's because I'm silly and forgot something.

    string viewName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:GoToView", NamespaceManager).Value;

    Hilary Stoupa

  • 11-21-2012 08:13 AM In reply to

    Re: ViewInfos.SwitchView getting view name from field

    Thanks you very much. It's working perfectly.

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