Erro in OnAfterChange event

L

Lisa

I have some code modeled after the sample invoice
(multiple tax rates) in the OnAfterChange of a detail
section. After a few lines of entry, I get an error:

"A run-time error has occurred. Do you want to debug? The
following error occurred: A script error occurred. The
number of calls to the OnAfterChange event for a single
update in the data exceeded the naximum limit.
File:script.js Line:378"

The code:

function setNodeTypedValue(xpath, value)
{
var xmlNode = getNode(xpath);

if (!xmlNode)
return;

// The xsi:nil needs to be removed before we set the
value.
if (value != "" && xmlNode.getAttribute("xsi:nil"))
xmlNode.removeAttribute("xsi:nil");

var convertedValue = convertJScriptNumberToXML(value);

// Setting the value would mark the document as dirty.
// Let's do that if the value has really changed.
if (xmlNode.nodeTypedValue != convertedValue)
xmlNode.nodeTypedValue = convertedValue;
}


Line 378 is the last line (xmlNode.nodeTypedValue =
convertedValue)

I am using SP1. Has anyone else encountered this error or
understand what it is complaining about?

Thanks.
 
L

Lisa

Thank you. Your explanation made sense. I went back and
looked at the sample code I modeled mine against and
realized what I was missing (now that I have a better
understanding).
Thanks again.
-----Original Message-----
Sounds like you are experiencing recursion, or an endless
loop. This is a common problem, that CAN be overcome.
What is happening is that you have an OnAfterChange event
handler set up on a node or a group... but in that handler
you are also modifying that node, or a node within that
group. This change fires off another OnAfterChange event
which then makes another modification, which fires
again... and so on.
Please see my InfoPathDev.com Dev Nugget
titled, "Avoiding an Endless Loop During Event Bubbling"
for details on this. If after reading this and reworking
your code a bit you are still having trouble, reply here
with your experiene and more details and we'll see if we
can't get it solved for you!
--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



"Lisa" <[email protected]> wrote in
message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top