Code does not work on Web Form - InfoPath Dev
in

InfoPath Dev

Code does not work on Web Form

Last post 03-01-2011 12:01 PM by Michael Vasquez. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-01-2011 08:59 AM

    Code does not work on Web Form

    I have a function that counts the number of attendees in a schedule class data and assign the next seat number according to what the count is.  It works in Infopath but does not work on an Infopath Web form.  In the Infopath Web form, it always returns one.  I have searched and searched for an another but to no avail.  Her is the code.  I was wondering if anyone would know how to do this using rules.  I tried figuring out how to use rules but could not.

    Public Function setSeatNum() As Integer

    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 xForm As XPathNavigator = Me.CreateNavigator()
    Dim formClassDate As Date = xForm.SelectSingleNode("/my:SharePointTraining/my:dClassDate", ns).Value
    Dim seatNum As XPathNavigator = xForm.SelectSingleNode("/my:SharePointTraining/my:seat", ns)
    Dim availSeats As XPathNavigator = xForm.SelectSingleNode("/my:SharePointTraining/my:AvailSeats", ns)
    Dim cnt As Integer
    Dim dClassDate As Date

    While (SeatIter.MoveNext())

       classDate.MoveNext()
       dClassDate = classDate.Current.Value
       If formClassDate = dClassDate Then
          cnt = cnt + 1
       End If

       If formClassDate > dClassDate Then
        Exit While
       End If
    End While

    If cnt > 1 Then
       seatNum.SetValue(cnt)
       availSeats.SetValue(CStr((10 - cnt)))
    ElseIf cnt = 0 Then
       seatNum.SetValue(cnt + 1)
       availSeats.SetValue(CStr(10))
    Else
       seatNum.SetValue(cnt + 1)
       availSeats.SetValue(CStr(10) - cnt)
    End If

    'clean up

    xPath = Nothing
    ns = Nothing
    SeatIter = Nothing
    classDate = Nothing
    xForm = Nothing
    formClassDate = Nothing
    seatNum = Nothing
    availSeats = Nothing

    End Function

    Thanks, in advance

     

    Mike

  • 03-01-2011 10:32 AM In reply to

    Re: Code does not work on Web Form

    Hi Michael,

    What version of SharePoint are you using?

    If it's SharePoint 2007 did you make sure to admin deploy the form and approve it in SharePoint?  That is required with a web form with code. 

    If you are using SharePoint 2010 you can admin deploy or you can use the sandbox (no admin deploy required).

    Hope that helps

    Ted

  • 03-01-2011 12:01 PM In reply to

    Re: Code does not work on Web Form

    Yes, I have admin deployed.  I am using SharePoint2007.

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