Calculating Business Days Between Two Dates - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Calculating Business Days Between Two Dates

Last post 05-31-2019 12:58 PM by mrosenstein. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-24-2019 01:15 PM

    Calculating Business Days Between Two Dates

    I am attempting to follow the alecpojidaev instructions to calculate the amount of working days between two date pickers on my own form using this link: https://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/ . However, after copying his rules directly from his form and running it on my own form, I continue to get errors. The error received when I choose a date on my form is: An error occurred in the form's rules or code. The number of rule actions or the number of calls to the OnAfterChange event for a single update in the data exceeded the maximum limit. The rules or code may be causing an infinite loop. To prevent this, ensure that the rule action or event handler does not update the data which causes the same rule action or event handler to execute. Is anyone aware of a quick fix to remedy these errors?
  • 05-29-2019 08:26 AM In reply to

    Re: Calculating Business Days Between Two Dates

    I don't know of any specific pointers on what you may have in your form rules that is causing this - but I'd be happy to take a look at it to see if I can help you. You can attach a copy of your form under the Options tab in a reply.
    Hilary Stoupa

  • 05-29-2019 01:09 PM In reply to

    Re: Calculating Business Days Between Two Dates

    The variables within this form that I'm working with to calculate the business days is "firstday", "lastday", "BegDateWN", "EndDateWN", and "workDays". I think the issue arises with BegDateWN and EndDateWN. When using the design checker, I get a warning which states "The custom control has duplicate attributes or elements. Please check the XSL to ensure there are no duplicate values." which I believe corresponds to Rule 2 within those variables.
  • 05-29-2019 02:26 PM In reply to

    Re: Calculating Business Days Between Two Dates

    I've gotten you a little closer, I think - save the attached file locally, right click, select Design and then you can preview, etc. The main diff I saw between your form and the sample you linked is that your form is a SharePoint list form, so you don't have plain date datatypes - even if the list is set to only display dates, it will store date/times. So I had to modify any reference to the firstday and lastday fields to use substring-before(field, "T") to return the just date part. However, I was still occasionally seeing the calc error - I just don't have time today to see if I can discern a pattern. Maybe you can try some different date combos and see if you can see when it fails? :-)
    Hilary Stoupa

  • 05-29-2019 03:16 PM In reply to

    Re: Calculating Business Days Between Two Dates

    Thank you so much for your help! From what I can see, the error seems to result from the variable "totalhours" which calculates a value using "workDays" to calculate total working hours. Do you know the best way to go about doing that without getting an error for number of calculations exceeding the maximum limit?
  • 05-29-2019 04:13 PM In reply to

    Re: Calculating Business Days Between Two Dates

    Good detective work! Try this one - I moved the total hours from a default value to an action on the BegDateWN / EndDateWN fields - on the second rule where you are setting the work days. You'll want to test this carefully in the browser tho - sometimes browser forms can be a bit more persnicketty, so something that is working in preview may still fail in the published form.
    Hilary Stoupa

  • 05-31-2019 12:58 PM In reply to

    Re: Calculating Business Days Between Two Dates

    Thank you so much for all of your help! I would not have been able to figure it out on my own.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.