Why a For loop does not work in a Web Form Browser - InfoPath Dev
in

InfoPath Dev

Why a For loop does not work in a Web Form Browser

Last post 10-31-2011 06:51 AM by Michael Vasquez. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-28-2011 11:27 AM

    Why a For loop does not work in a Web Form Browser

    Why does the below code in the Infopath Form work but does not work in a Web enabled Form.  How can I fix this.  I have posted this in many posts without a resolution.

    Dim xPath As XPathNavigator = DataSources("SharePoint Training").CreateNavigator()
    Dim ns As XmlNamespaceManager = Me.NamespaceManager
    Dim SeatIter As XPathNodeIterator = xPath.Select("/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training/@Seat__", ns)
    Dim classDate As XPathNodeIterator = xPath.Select("/dfs:myFields/dfs:dataFields/dfs:SharePoint_Training/@Class_Date", ns)
    Dim formClassDate As String = xForm.SelectSingleNode("/my:SharePointTraining/my:dClassDate", ns).Value
    Dim availSeats As XPathNavigator = xForm.SelectSingleNode("/my:SharePointTraining/my:AvailSeats", ns)
    Dim cnt As String = 0

    For i = 1 To 15
      classDate.MoveNext()
      sDate = Left(classDate.Current.Value, 10)

      If sDate = formClassDate Then
        cnt = cnt + 1
      Else
        Exit For
      End If
    Next

    availSeats.SetValue(cnt)

    The cnt is 0 in the Web enabled form and currently, it should be 2

    The sharepoint list contains many previous dates of the same class.  I want to get the total count of available seats for an upcoming class

    Is there a way I can accomplish the same thing using rules.

    TIA Mike

  • 10-28-2011 03:11 PM In reply to

    Re: Why a For loop does not work in a Web Form Browser

    Hi - I replied to your other post with a sample on using a rule to get this information - there is no reason you should have to use code for it: http://www.infopathdev.com/forums/p/20624/71436.aspx#71436

    I'm not sure why your code is failing in the browser - any errors? You may want to add a try catch and populate another field with any error messages to track it down.

    Hilary Stoupa

  • 10-31-2011 06:51 AM In reply to

    Re: Why a For loop does not work in a Web Form Browser

    I sent you another reply in a previous post.  I will try the try::catch.  Currently, when I run the for loop, I get no errors in the Web form.

    Thanks,

    Mike

     

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