Iterate resource file and select a node if it falls between two dates - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Iterate resource file and select a node if it falls between two dates

Last post 10-25-2012 08:37 AM by Hilary Stoupa. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 10-23-2012 08:56 PM

    Iterate resource file and select a node if it falls between two dates

    I have imported a resource file and have set a bunch of default values that have rates and when they begin and when they end.

    In my form, I need to pick a date, and I would like to run through my default values and choose a rate if my date falls between the start and end dates.

    For example, I could choose 10/15/2012. So it looks at the list and it finds a node that has a start date of 10/1/2012 and an end date of 10/31/2012 with a rate of $200.

    So it would populate the control with $200.

    Does that make sense?

    Any help is appreciated. Actually, if you can just point me to the correct documentaiton that would be great.

     

    Thanks.

    Filed under: ,
  • 10-24-2012 08:15 AM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    Hi - I updated the sample form to show this. I changed the fields to a date datatype, and changed the format of the original data so it was correct for XML dates (yyyy-MM-dd).The rule is on field1 & sets field2 to the rate. It was a little counter-intuitive for me - we want the row where the start date is less than the selected date and the end date is greater than the selected date - I kept getting the greater than / lesser than wrong and had to use some conditional formatting on the table to straighten out my thinking. :)

    Hilary Stoupa

  • 10-24-2012 12:10 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    Ok, I think I am almost there. At least it cant find errors in the formulas. However, it does not show rates. I "think" it has to do with the date format.

    Here is what I have in my resource.xml file that is used to populate the default values:

    <PerDiem>
    <Rate start="2011-10-1" end="2011-10-31">248.60</Rate>
    <Rate start="2011-11-1" end="2012-2-28">201.30</Rate>
    <Rate start="2012-3-1" end="2012-6-30">246.00</Rate>
    <Rate start="2012-7-1" end="2012-8-31">185.90</Rate>
    <Rate start="2012-9-1" end="2012-9-31">248.60</Rate>
    <MealStart>53.25</MealStart>
    <MealDuring>71.00</MealDuring>
    </PerDiem>

    The dates look good to me. However, when I run the form and save it, it comes out like this:

    <my:PerDiem>
      <my:MealStart>53.25</my:MealStart>
      <my:MealDuring>71.00</my:MealDuring>
      <my:Lodging>
       <my:rate>248.60</my:rate>
       <my:start>10/1/2011</my:start>
       <my:end>10/31/2011</my:end>
       <my:reset></my:reset>
      </my:Lodging>
      <my:Lodging>
       <my:rate>201.30</my:rate>
       <my:start>11/1/2011</my:start>
       <my:end>2/28/2012</my:end>
       <my:reset></my:reset>
      </my:Lodging>
      <my:Lodging>
       <my:rate>246.00</my:rate>
       <my:start>3/1/2012</my:start>
       <my:end>6/30/2012</my:end>
       <my:reset></my:reset>
      </my:Lodging>
      <my:Lodging>
       <my:rate>185.90</my:rate>
       <my:start>7/1/2012</my:start>
       <my:end>8/31/2012</my:end>
       <my:reset></my:reset>
      </my:Lodging>
      <my:Lodging>
       <my:rate>248.60</my:rate>
       <my:start>9/1/2012</my:start>
       <my:end>9/31/2012</my:end>
       <my:reset></my:reset>
      </my:Lodging>
     </my:PerDiem>

    I cant find where it is changing the date. I have set the data type to Date everywhere I can think of.

    Thanks.

    Filed under: ,
  • 10-24-2012 12:17 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    2012-09-31 isn't a valid date - you'll want to fix that.

    In your form's main data source, are my:start and my:end set to date data types?

    Is your form using a resource file that is part of the form templates in the secondary data connection? If so, did you update it with your fixed XML? Or is the XML external to the form?

    Hilary Stoupa

  • 10-24-2012 02:45 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    Ok, I fixed the 2012-09-31 issue.

     

    Yes, the data types are set to Date.

    I am not sure how to answer your final question. I imported an external xml file into a resource file. I am not sure however I got the terminology correct so I attached my form. If you could look at it that would be great.

     

    Thanks,

    Filed under: ,
  • 10-24-2012 03:00 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    When you added the data connection to your XML file, the form probably asked if you wanted to include the XML as a resource for the form, or access it from its current location. Looking at your form, I can see you opted to import the XML. So, the form template itself now has a copy of that XML with its other files - on the data tab in the ribbon, select Resource Files (undert tools in IP 2007) and you can see the file there. Export it, and you'll see it is your original file - with the data values formatted in a way that XML won't recognize as dates.

    You can walk through the data connection wizard again and select your XML file again - if it is not on a local network (i.e., it is on a SharePoint site or something) you should have an option to access the data from that location instead of including it with the template, which is, I think, what you want so that you don't have to update the template every time the data changes.... does that make sense?

    Here is some more information that may be helpful.

    Hilary Stoupa

  • 10-24-2012 06:02 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    So, it says that "Connections to XML files on the local computer are supproted only in fully-trusted form templates." That is just as well, since I want to mail this to people and don't want to send the data file with it.

     

    So, I updated the file, but it still does not work. When I export the file or save the form, the data all looks correct now, but it just wont show the rate.

    Filed under: ,
  • 10-24-2012 06:38 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    Attaching a revised version - I fixed up the formula on your rule to set "field2". Since it was being set to a decimal, I changed its data type - you had it as a date?

    I feel like I'm not explaining resource files well. Originally, you'd mentioned wanting to be able to update the rates w/out having to change the form template - this is why I was thinking you'd want to use an external XML data source (i.e., file on SharePoint). So, it sounds instead like you want the XML included with the template - that's what you currently have, but you'll have to update the template (and send it to people again) when you need to change the data in there (rate start & end, for example). I hope that makes sense.

    Hilary Stoupa

  • 10-24-2012 08:27 PM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    Wow, you have been so helpful. Thank you.

     Yes, I did understand what you said, but when I said that I did not want to update the rates without having to change the form template, what I meant is that I didn't want to have to open the Default Values and set them all by hand every time they changed.

    Depending on how I end up using this, I may or may not use an external xml file, but at least I now know how to use both. This is wonderful and you have helped immensly.

    Thanks

    Filed under: ,
  • 10-25-2012 06:37 AM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    By the way, do you know if there is any tool like Infopath for creating style sheets? I am creating spreadsheets and html pages to discplay my xml data but it is slow going, trial and error to get it to look right. A tool like infopath would be great.

    Filed under: , ,
  • 10-25-2012 08:37 AM In reply to

    Re: Iterate resource file and select a node if it falls between two dates

    When you say style sheets, what do you mean? XSL / XSLT?

    Your InfoPath template is a collection of different files, including XSL files for the views. Under Publish, you have the option to export source files - do that, and you'll be able to see the XSL for your different views - you can open them in a text editor or whatever and see what InfoPath is using for display - that may be helpful.

    Hilary Stoupa

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