I am pretty new to infopath and have been trying to get a hang of the rules and the xpath syntax. I made a date processor (using the codeless infopath tutorial #2 http://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/). However, I am getting some inconsistant errors and I can not determine why. The .xsn can be downloaded from: http://www.filedropper.com/datecalculationform1b (I used filedropper, which seems to be relatively painless when it comes to popups and other garbage).
Basically I do this -
I have two dates, startDate & endDate. They both have rules that if either one changes and the other is not blank then it sets dayDifference to "0;4096" (I assume this is some type of place-holder value?)
dayDifference is set to fire off a rule when:
1. xdDate:AddDays(../my:startDate, substring-before(., ";")) != ../my:endDate
2. dayDifference contains ";"
and sets itself to:
concat(substring-before(., ";") + substring-after(., ";") * ((translate(addDays(startDate, substring-before(., ";")), "-", "") < translate(endDate, "-", "")) * 2 - 1), ";", substring-after(., ";") / 2)
Then a second rule which is set to fire when:
1. dayDifference contains ";"
and sets itself to:
substring-before(., ";")
Everything is fine up to this point. I start to run into problems when I attempt to do something with dayDifference. I added another rule set to fire when dayDifference does not contain ";" which sets another field (noOfDaysBetweenPayments) to dayDifference / noOfPayments.
I am pretty sure this is the point that the error crops up, but I am not sure why because it does not happen everytime I update/ change one of the dates.
Any help would be appreciated. Thanks!
Also, I am new to xpath and am wondering is it _really_ necessary to have all that concat, translate, substring-before business to do something as straight-forward as find the difference between two dates?