<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: onAfterChange code executes twice</title><link>https://www.infopathdev.com:443/forums/thread/52463.aspx</link><pubDate>Thu, 04 Mar 2010 16:18:35 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52463</guid><dc:creator>zxkuqyb</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52463.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52463</wfw:commentRss><description>&lt;p&gt;Jimmy,&lt;/p&gt;
&lt;p&gt;Thank you for this...it works perfectly.&amp;nbsp; Much appreciated!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thomas N. Barrett&lt;/p&gt;</description></item><item><title>Re: onAfterChange code executes twice</title><link>https://www.infopathdev.com:443/forums/thread/52461.aspx</link><pubDate>Thu, 04 Mar 2010 15:59:41 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52461</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52461.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52461</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;This is the problem:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; if (!eventObj.IsUndoRedo &amp;amp;&amp;amp; eventObj.Operation == &amp;quot;Delete&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; eventObj.Site.nodeName == &amp;quot;item&amp;quot; &amp;amp;&amp;amp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eventObj.Source.nodeName == &amp;quot;item&amp;quot;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;return;&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;This causes the handler to exit only if:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;A Delete operation is being performed AND&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The node that triggered the event is called &amp;quot;item&amp;quot; AND&lt;/li&gt;&lt;li&gt;The node being modified is called &amp;quot;item&amp;quot;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Since your node is not called &amp;quot;item,&amp;quot; this if statement will never cause the event handler to exit and the event handler will always run twice (once for the Delete event and once for the Insert event) every time the field is modified.&amp;nbsp; Try changing the above to this:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;if(eventObj.IsUndoRedo || eventObj.Operation == &amp;quot;Delete&amp;quot;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I&amp;#39;d also suggest refactoring your code a bit.&amp;nbsp; It looks like you have the exact same large chunk of code repeated three times.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: onAfterChange code executes twice</title><link>https://www.infopathdev.com:443/forums/thread/52457.aspx</link><pubDate>Thu, 04 Mar 2010 15:13:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52457</guid><dc:creator>zxkuqyb</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52457.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52457</wfw:commentRss><description>&lt;p&gt;I appologize for the redundancy, but I&amp;#39;m experiencing a similar issue and can&amp;#39;t figure out what I&amp;#39;m doing wrong.&amp;nbsp; Basically, I have a &amp;quot;Status&amp;quot; field and when it changes, I want to append to the history that the Status has changed...the history is appending twice and am not sure how to have it append once...any help would be greatly appreciated...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thanks&lt;/p&gt;
&lt;p&gt;Thomas N Barrett&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;function msoxd_my_Approval_Status::OnAfterChange(eventObj)&lt;br /&gt;{&lt;br /&gt;// Write code here to restore the global state.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; if (!eventObj.IsUndoRedo &amp;amp;&amp;amp; eventObj.Operation == &amp;quot;Delete&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; eventObj.Site.nodeName == &amp;quot;item&amp;quot; &amp;amp;&amp;amp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eventObj.Source.nodeName == &amp;quot;item&amp;quot;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;return;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;var StatusChoice = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:InputData/my:Approval_Status&amp;quot;).text&lt;/p&gt;
&lt;p&gt;&amp;nbsp;switch (StatusChoice)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case &amp;quot;Approved&amp;quot;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text = &amp;quot;Approved&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text = todaysDate();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append to History that the Current Status has changed...Also, capture Username and Date / Time stamp of the Current Status change&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var CurrentUser = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:AdminSection/my:Current_User_Name&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var newComment = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:NewCommentGroup/my:NewComment&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the individual nodes (for the Comment History Table)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistoryTableRows = XDocument.DOM.createNode(1, &amp;quot;CommentHistoryTable&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentUserName = XDocument.DOM.createNode(1, &amp;quot;CommentUserName&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentDate = XDocument.DOM.createNode(1, &amp;quot;CommentDate&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistory = XDocument.DOM.createNode(1, &amp;quot;CommentHistory&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the node structure for the Comment History Table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentUserName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentDate);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentHistory);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append Values&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentUserName.text = CurrentUser;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentDate.text = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistory.text = &amp;quot;Current Status changed to: &amp;quot; + XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append row to XML document&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var parent = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:CommentHistoryGroup&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent.appendChild(nodeCommentHistoryTableRows);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case &amp;quot;In Process&amp;quot;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text = &amp;quot;In Process&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text = todaysDate();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append to History that the Current Status has changed...Also, capture Username and Date / Time stamp of the Current Status change&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var CurrentUser = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:AdminSection/my:Current_User_Name&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var newComment = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:NewCommentGroup/my:NewComment&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the individual nodes (for the Comment History Table)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistoryTableRows = XDocument.DOM.createNode(1, &amp;quot;CommentHistoryTable&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentUserName = XDocument.DOM.createNode(1, &amp;quot;CommentUserName&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentDate = XDocument.DOM.createNode(1, &amp;quot;CommentDate&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistory = XDocument.DOM.createNode(1, &amp;quot;CommentHistory&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the node structure for the Comment History Table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentUserName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentDate);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentHistory);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append Values&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentUserName.text = CurrentUser;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentDate.text = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistory.text = &amp;quot;Current Status changed to: &amp;quot; + XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append row to XML document&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var parent = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:CommentHistoryGroup&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent.appendChild(nodeCommentHistoryTableRows);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;case &amp;quot;Rejected&amp;quot;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text = &amp;quot;Rejected&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text = todaysDate();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append to History that the Current Status has changed...Also, capture Username and Date / Time stamp of the Current Status change&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var CurrentUser = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:AdminSection/my:Current_User_Name&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var newComment = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:NewCommentGroup/my:NewComment&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the individual nodes (for the Comment History Table)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistoryTableRows = XDocument.DOM.createNode(1, &amp;quot;CommentHistoryTable&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentUserName = XDocument.DOM.createNode(1, &amp;quot;CommentUserName&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentDate = XDocument.DOM.createNode(1, &amp;quot;CommentDate&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var nodeCommentHistory = XDocument.DOM.createNode(1, &amp;quot;CommentHistory&amp;quot;, &amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-16T18:51:51&lt;/a&gt;&amp;quot;);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the node structure for the Comment History Table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentUserName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentDate);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistoryTableRows.appendChild(nodeCommentHistory);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append Values&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentUserName.text = CurrentUser;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentDate.text = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_Change_Date&amp;quot;).text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nodeCommentHistory.text = &amp;quot;Current Status changed to: &amp;quot; + XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:Admin/my:Approval_Status_FLAG&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Append row to XML document&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var parent = XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:CommentHistoryGroup&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent.appendChild(nodeCommentHistoryTableRows);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;
&lt;p&gt;// A field change has occurred and the DOM is writable. Write code here to respond to the changes.&lt;br /&gt;}&lt;/p&gt;</description></item><item><title>Re: onAfterChange code executes twice</title><link>https://www.infopathdev.com:443/forums/thread/14870.aspx</link><pubDate>Sat, 04 Nov 2006 00:25:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14870</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14870.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14870</wfw:commentRss><description>First off, you should move the IsUndoRedo above the other code. The event handlers will enter multiple times with different actions. I don't remember but think that Checkbox may always enter with both a Delete and an Insert, you'll want to add some code to check. Here's a reference:&lt;br /&gt;&lt;br /&lt;a target="_blank" href=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/xdproOperation_2_HV01021316.asp&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/xdproOperation_2_HV01021316.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;function msoxd__item::OnAfterChange(eventObj)&lt;br /&gt;{&lt;br /&gt;   if (!eventObj.IsUndoRedo &amp;&amp; eventObj.Operation == "Delete"&lt;br /&gt;      &amp;&amp; eventObj.Site.nodeName == "item" &amp;&amp; &lt;br /&gt;         eventObj.Source.nodeName == "item")&lt;br /&gt;   {&lt;br /&gt;      Calculate();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Above, the code is checking for just Delete. Add a breakpoint to your code and see if the action is different. My guess is that it is and you need to filter out one.</description></item><item><title>onAfterChange code executes twice</title><link>https://www.infopathdev.com:443/forums/thread/12974.aspx</link><pubDate>Fri, 03 Nov 2006 18:15:41 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12974</guid><dc:creator>skydolphin</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12974.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12974</wfw:commentRss><description>I have a check box that at the moment is just opening a word document when the box is checked.  The code seems to be executing twice.  Anyone have any idea why?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;function msoxd_my_adddoc::OnAfterChange(eventObj)&lt;br /&gt;{&lt;br /&gt;// Write code here to restore the global state.&lt;br /&gt;	var adddoc = XDocument.DOM.selectSingleNode("/my:SCInvoice/my:Header/my:adddoc").text;&lt;br /&gt;	if (adddoc == "true")&lt;br /&gt;	{&lt;br /&gt;		var doc = new ActiveXObject("Word.Application"); &lt;br /&gt;		doc.Visible=false; &lt;br /&gt;		doc.Documents.Open("Something.doc"); &lt;br /&gt;	}&lt;br /&gt;	if (eventObj.IsUndoRedo)&lt;br /&gt;		{&lt;br /&gt;			// An undo or redo operation has occurred and the DOM is read-only.&lt;br /&gt;			return;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;// A field change has occurred and the DOM is writable. Write code here to respond to the changes.&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</description></item></channel></rss>