Hello,
Please help me to understand what is going on with my C# managed code in InfoPath 2013. When I click the button for "Fill RT from Trigger", the method
"Fill_Repeating_Table_Clicked" method runs the method "Fill_RT()" one time like I expected. When I change the value of a field that triggers
the "RTTrigger_Changed" event, the method "Fill_RT()" gets ran two times! I don't understand why it runs twice when I changed the RTTrigger field just once?
How can I get the Fill_RT() to run just one time when the field changed event occurs? I have attached the .xsn file. I'm not sure if that includes the managed code or not, but the gist of it is below.
My Rule based on an "on after changed event" for field RTTrigger:
Set a field's value: Incremented = Incremented + 1
Set a field's value: RTTrigger = Incremented
public void InternalStartup()
{
((ButtonEvent)EventManager.ControlEvents["Fill_Repeating_Table"]).Clicked += new ClickedEventHandler(Fill_Repeating_Table_Clicked);
EventManager.XmlEvents["/my:myFields/my:RTTrigger"].Changed += new XmlChangedEventHandler(RTTrigger_Changed);
}
public void Fill_Repeating_Table_Clicked(object sender, ClickedEventArgs e)
{
string linebreak = "\r\n";
XPathNavigator root = this.CreateNavigator();
XPathNavigator myDebug = root.SelectSingleNode("/my:myFields/my:DebugInfo", NamespaceManager);
myDebug.SetValue(myDebug.Value + "Fill_Repeating_Table_Clicked" + linebreak);
// clean up
myDebug = null;
root = null;
Fill_RT();
}
public void RTTrigger_Changed(object sender, XmlEventArgs e)
{
string linebreak = "\r\n";
XPathNavigator root = this.CreateNavigator();
XPathNavigator myDebug = root.SelectSingleNode("/my:myFields/my:DebugInfo", NamespaceManager);
myDebug.SetValue(myDebug.Value + "RTTrigger_Changed" + linebreak);
// clean up
myDebug = null;
root = null;
Fill_RT();
}