Count field and group by date - InfoPath Dev
in

InfoPath Dev

Count field and group by date

Last post 07-23-2010 04:16 PM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-22-2010 10:10 AM

    Count field and group by date

    I have created an InfoPath form (Web enabled) that schedules training for a specific data.  Two of the fields are used to set the next seatNum and also to show the available seats left on a specific date. When I use the InfoPath form it works.  When I used the Web enabled form I get a 5337 error and the available seats is not calculated.  I checked the Design Checker and it returned no errors or messages.  My data connection point to the same SharePoint site where the form is located so there is no double hop issue.  The form is set to Full Trust  Below is the code I use to calculate those two fields.

    Why does this not work when the form is Web enabled?

    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

          cnt = cnt + 1

          Exit While

       End If

    End While

     

    If cnt > 0 Then

       seatNum.SetValue(cnt)

    End If

     

    availSeats.SetValue(CStr((11 - cnt)))

    TIA Mike

  • 07-22-2010 02:24 PM In reply to

    Re: Count field and group by date

    Hi Mike,

    I'm not a huge VB person and I can't even tell the difference between VB.NET and VBscript - browser obviously will not support VBscript, so please verify it's VB.NET or C#.NET. Sorry I can't tell just by looking at the code anymore. I used to be able to do that but haven't been coding in quite a while.

    Assuming that isn't an issue, you should probably make sure the form is admin deployed. Full Trust forms will require Admin Deploy.

    Finally, have you searched Google for the error code?

     

    Patrick Halstead
    Project Manager at Qdabra
  • 07-22-2010 03:03 PM In reply to

    Re: Count field and group by date

    It is vb.net.  I have googled the error code for weeks and have done what they have suggested to no avail.

     

    Mike

  • 07-22-2010 04:03 PM In reply to

    Re: Count field and group by date

    Could be a problem with your SharePoint server. Have you checked the SharePoint logs?

    Patrick Halstead
    Project Manager at Qdabra
  • 07-23-2010 08:34 AM In reply to

    Re: Count field and group by date

    The one thing I've seen in common with the errors is that they all refer to an exception in the code -- so it would seem there is something in your code that causes an exception when it runs in the browser but not in the client.

    I know that probably sounds obvious -- and the question is obviously "But WHAT is causing the exception???" And I don't have an answer for that, but I do know that in the past one way I've worked out where the issue is in the browser is by commenting out parts of my code and seeing if I still get an error, then gradually re-enabling things, so I can narrow down WHERE the error is. Then you'll have something more specific to search out than a rather unhelpful error code.

    You should also check your server logs, to see if you can get more info. These logs are located on the server, generally at: C:\Program Files\Common Files\Microsoft Shared\web server
    extensions\12\LOGS. I normally try to provoke an error RIGHT before I open the latest log file, to make it easier to find.

    Hilary Stoupa

  • 07-23-2010 02:55 PM In reply to

    Re: Count field and group by date

    Hilary, thanks for your advice.  I commented out most of the code and it started to work.  So I started removing the comments ( ' ) one line at a time.  I realized that I was assigning a value to the Web enabled form, I was trying to assign a date value.  When I casted the date to a string, CStr() , it worked.  I just have to remember any value you assigned to a Web enabled form should be casted as a string.

     Again,  Thank,s

    Mike

  • 07-23-2010 04:16 PM In reply to

    Re: Count field and group by date

    Wonderful -- glad you got it sorted out! That whole "comment out, publish, admin approve, test" cycle is a treat, isn't it?

    Hilary Stoupa

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