On after change event error - InfoPath Dev
in

InfoPath Dev

On after change event error

Last post 04-03-2007 07:39 AM by lou131. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 03-30-2007 08:39 AM

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    On after change event error

    Hi,

    I have a repeating table with calculations and rules. I'm getting the following error:

    The number of calls to the On after change event for a single update in the data exceeded maximum limit.

    How do I resolve this issue?
    Thanks
    Lou
  • 03-30-2007 09:28 AM In reply to

    Re: On after change event error

    Sounds like you have the same old problem of your OnAfterChange event handler updating someting which causes the handler to get called again.

    The easiest way to prevent this is to set a global flag (variable) which states that your OAC event handler is making DOM changes. Then at the top of your handler, if that flag is set to true, return out and don't process that event further.

    Then just set the flag to false when done, so that you handler works again later.
  • 03-30-2007 09:32 AM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    This is great and thanks for the reply....but please excuse my ignorance. I'm new to infopath and especially new to doing coding. Can you be a more specific with an example of the coding and where I should put it.
    Thanks
    Lou
  • 03-30-2007 12:35 PM In reply to

    Re: On after change event error

    public void SomeField_OnAfterChange(...)
    {
    if(e.UndoRedo || e.Operation != "Insert" || fIsUpdatingFields == true)
    return;

    fIsUpdatingFields = true;

    // Modify DOM here.

    fIsUpdatingFields = false;
    }
  • 03-30-2007 12:56 PM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    Thanks Greg....my repeating table has a column that has a drop down choice. Based on the choice, the fields do different calculations. The issue pops up when I change a choice in the drop down but seems to work fine when I select the defaulted choice when the form opens. I put your code in but still seeing the issue. Is this a more complex thing or maybe I just copied the code in wrong. I put the code in the Context Change Event Handler and just inserted it into an open space.

    Thanks again for the help.
    Lou
  • 03-30-2007 01:33 PM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    One more point....when I get the error in preview mode and go back to the Context Change Event Handler, the following is automatically inserted.

    function XDocument::OnContextChange(eventObj)
    {

    if (eventObj.Type == "ContextNode")
    {
    // Selection or context in the form has changed. Write your code here to respond to the changes.
    return;
    }

    }

    Thanks
    Lou
  • 04-02-2007 05:57 AM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    Greg,
    Any other thoughts on the additional info above. After I make the change in my drop down, I get the error when I try to insert another row. The above info is then inserted into event handler. I'm doing something wrong. Any additional help would be appreciated.
    Thanks
    Lou
  • 04-02-2007 09:35 AM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    I guess I don't understand.....// Modify DOM here.

    Im sure it's very simple but I'm not a coder so the simplest of things is difficult.
    Thanks
    Lou
  • 04-02-2007 01:30 PM In reply to

    Re: On after change event error

    The code I wrote was just a skeleton of your onafterchange event. It was demonstrating the use of a flag to prevent endless loops: i.e. the onafterchange event handler causing another call to the same hanlder, and so on...

    You will need to write your own code to do accomplish what you want inside the handler.
  • 04-03-2007 07:39 AM In reply to

    • lou131
    • Top 100 Contributor
    • Joined on 02-13-2007
    • USA
    • Posts 89

    Re: On after change event error

    ok...thanks for the reply.
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.