Why do I get these errors? - InfoPath Dev
in

InfoPath Dev

Why do I get these errors?

Last post 09-16-2012 07:54 PM by politicue. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-11-2012 08:44 AM

    Why do I get these errors?

    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?

  • 09-11-2012 09:40 PM In reply to

    Re: Why do I get these errors?

    politicue:
    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?
     

    IMO, there is no need to have such Xpath complexities or specially to study Xpath syntax at all.

    The reason of it is avoiding any code-behind and related to it maintenance/administration hassles as explained in part 1 of the cited series (Alec Pojidaev's InfoPath Blog.Infopath codeless programming (walkthrough) 1)::

    •  "Let me guess what might have brought you to that blog page about codeless programming in InfoPath.

      Any of you who developed at least one sophisticated InfoPath form sooner or later have been realized that writing forms with real complex behavior is impossible without some sort of coding in C# or VB.NET. So developers have no choice but to deal with mixed developing environment like Visual Studio, managing form security levels, security certificates and so on. But there are people who like to keep things simple. At least I do. And that’s why probably you are reading that page too:)"

    This is highly subjective what is "simple". One man's meat is another man's poison

    I do not believe that it is possible to completely avoid any code-behind for all possible required necessities, so such "simplicity" will eventually end up in lost of time, efforts and maintenance nightmare  

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 09-12-2012 02:41 AM In reply to

    Re: Why do I get these errors?

    The formula in this approach is a lot nastier, but there is a way to do date diff with a single formula and avoid that complicated rule logic:

    http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm

    There's also the option of qRules, which makes date diffs (and a lot of other stuff) a piece of cake.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-16-2012 07:54 PM In reply to

    Re: Why do I get these errors?

    Thanks for the help. I figured out I was running into the 16 updates with no user interaction limit. Coding your own solution is definitely the way to go.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.