Friday, September 01, 2006 4:40 AM
by
bsandeman
Those wacky validating events
Now then, I have decided that the only way to solve the issue of repeated events and subsequent non-repeated events that I ended up with yesterday is to check the value of the field before continuing to execute the validating function such that if it is the same as the previous value, the validating code is not executed. This seemed fairly sensible really....
However, I have now discovered that it does not seem possible to actually get hold of the value of the field being validated while within the Validating event, see the following examples...
I entered as a user the value 1234 into my int field within the InfoPath form and then checked values in the debugger
public string getFieldValue(String xpath)
{
XPathNavigator XPN = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, this.NamespaceManager);
return XPN.Value;
}
// This places the value "" (empty string) into the variable currentValue
currentValue = getFieldValue("/ns1:Invoice/ns1:Order/ns1:SupplierNumber");
// This places the value "true" into the variable currentValue
currentValue = e.OldValue
// This places the value "" (empty string) into the variable currentValue
currentValue = e.NewValue
At this point it would seem impossible to perform validation using code in InfoPath 2007 B2 as you do not appear to have access to the value of the field which you are trying to validate! My impression of this is that it is an incomplete function and the developer has placed "true" as a default until the function is completed.