Hi all,
Ok.. I am using xdExtension:CalcDateDiff() in a rule to call some code in my infopath form.
The code is as follows:
public void CalcDateDiff()
{
XPathNavigator myNav = this.MainDataSource.CreateNavigator();
string dt1yr = myNav.SelectSingleNode("/my:myFields/my:orderDates/my:contractExit", this.NamespaceManager).Value.Substring(0, 4);
string dt1mth = myNav.SelectSingleNode("/my:myFields/my:orderDates/my:contractExit", this.NamespaceManager).Value.Substring(5, 2);
string dt1dy = myNav.SelectSingleNode("/my:myFields/my:orderDates/my:contractExit", this.NamespaceManager).Value.Substring(8, 2);
string dt2yr = myNav.SelectSingleNode("/my:myFields/my:shipping/my:finalDateETD", this.NamespaceManager).Value.Substring(0, 4);
string dt2mth = myNav.SelectSingleNode("/my:myFields/my:shipping/my:finalDateETD", this.NamespaceManager).Value.Substring(5, 2);
string dt2dy = myNav.SelectSingleNode("/my:myFields/my:shipping/my:finalDateETD", this.NamespaceManager).Value.Substring(8, 2);
DateTime firstDate = new DateTime(Convert.ToInt32(dt1yr), Convert.ToInt32(dt1mth), Convert.ToInt32(dt1dy));
DateTime secondDate = new DateTime(Convert.ToInt32(dt2yr), Convert.ToInt32(dt2mth), Convert.ToInt32(dt2dy));
TimeSpan diff = secondDate.Subtract(firstDate);
//MessageBox.Show(Convert.ToString(diff.Days));
myNav.SelectSingleNode("/my:myFields/my:shipping/my:etdDiff", this.NamespaceManager).SetValue(Convert.ToString(diff.Days));
}
When I preview the form and activate the code I get this error message:
"Exception has been thrown by the target of an invocation".. any ideas what that means??