grabbing values from a repeating table & comparing them with non-repeating fields - InfoPath Dev
in

InfoPath Dev

grabbing values from a repeating table & comparing them with non-repeating fields

Last post 04-08-2010 02:25 PM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-07-2010 01:41 PM

    grabbing values from a repeating table & comparing them with non-repeating fields

    (i am making a simple room booking form) What i want to do is this:

    The user picks a start and end date/time, then the date/time is displayed in non-repeating fields like this: 2010-04-07 12:30:00

    I need to take the user specified start & end date/times, and check to see if those times conflict with any of the times that have already been submited to the calendar library.

    My problem is how do i get all of the current calendar event start & end dates so I can compare them to what the user picked?

    Here's what I've got so far:

    XPathNavigator root = MainDataSource.CreateNavigator();string startdate1_RnRCompare = root.SelectSingleNode("my:myFields/my:startdate1",

    NamespaceManager).Value;

    string enddate1_RnRCompare = root.SelectSingleNode("my:myFields/my:enddate1",

    NamespaceManager).Value;



    //Here's the spot where i'm having trouble, I know grabbing a single node won't work....so what shall I do instead?

    string startdate2_RnRCompare = root.SelectSingleNode("dfs:myFields/dfs:dataFields/dfs:Conference_Room_Reservations/@startdate2",

    NamespaceManager).Value;

    string enddate2_RnRCompare = root.SelectSingleNode("dfs:myFields/dfs:dataFields/dfs:Reservations/@enddate2",

    NamespaceManager).Value;

    DateTime start1 = Convert.ToDateTime(startdate1_RnRCompare);

    DateTime end1 = Convert.ToDateTime(enddate1_RnRCompare);

    DateTime start2 = Convert.ToDateTime(startdate2_RnRCompare);

    DateTime end2 = Convert.ToDateTime(enddate2_RnRCompare);

    //my date comparison function belowstring test = (!((end2 < start1) || (start2 > end1))).ToString();

    //and here i'll do something with it

     

    Thanks!

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

    Re: grabbing values from a repeating table & comparing them with non-repeating fields

    Hi--

    You need to loop through all the nodes checking against the start and end dates. An XPathNodeIterator will help you here.

    Looking at your code, though, it looks like your start and end date are in different groups? Are both groups repeating?

    Hmmmm.... Looking more closely, it appears that you are selecting these start and end dates from the main data source? But aren't they in a different data source, a secondary data source?

    Hilary Stoupa

  • 04-08-2010 06:18 AM In reply to

    Re: grabbing values from a repeating table & comparing them with non-repeating fields

    Thanks, I'll check out nodeiterator

    The first two values, start1, end1 are from the main datasource. The user picks a start & end date from dropdown lists - start1/end1 are non-repeating.

    Start2 and end2 are from the secondary datasource and are repeating.

    When the user picks a start & end time, I am wanting to take those values and compare them to the secondary datasource.

    So if the user picked a time that overlaps with a start/end in the secondary datasource, infopath will tell them so through validation, switching view, etc.

    Edit: Actually, I'm not sure xpathnodeiterator and checking against the secondary datasource will be the way to go. I'm assuming if I do this that means I'll be retreiving the entire list every time someone opens the form, killing performance (right?). Should I be using the Sharepoint API to iterate through the list items instead so it's processed on the server? What do you think?

    Thanks!

  • 04-08-2010 02:25 PM In reply to

    Re: grabbing values from a repeating table & comparing them with non-repeating fields

    You are correct that your current architecture would require pulling down at least the start and end date for all your list items. If you anticipate this list getting big, you are smart to be thinking about future performance now.

    You could create a secondary data source connection to the list, and not query on load, then use a CAML query to see if any item exists in the list that matches the start and end date from your form. U2U CAML Query Builder can help you get an idea of what the CAML will need to look like.

    Hilary Stoupa

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