fieldRef.Validate Question

Hi everybody, I’m looking at the on-line help of “Ok := fieldref.VALIDATE([NewValue])” and I’m wondering how it works? To be more precise, I’d like to check for a field the table relation and if the onValidate trigger code succeeds. If yes then write the value and proceed normally but if not then do not write the value into the table. Actually I’m going to report the fail of the onValidate trigger into a log file. I’ve tried something like: If NOT myFieldRef.VALIDATE([NewValue]) THEN WriteError(ValidateError); The problem I have with the above part of code is that it does the check of the table relation and pop-up a message saying for example: ‘G/L Account 3000000 does not exist‘. What I want to do is to write this error to a log file instead of this message. I’m doing the same thing with INSERT and it works fine: IF NOT recRef.INSERT THEN WriteError(InsertError); Any ideas? Thank you.

Hi Pavlos from Greece… No you cannot do this. Try to turn off the ValidateTableRelation property of the Table and test for relation manualy. In this way you can trap the error and write it to a log file.

Hi Pavlos, you do two different things: If NOT myFieldRef.VALIDATE([NewValue]) THEN WriteError(ValidateError); With this code, you execute the Code behind the OnValidate-Trigger of the field. IF NOT recRef.INSERT THEN WriteError(InsertError); with this code you execute no code in any trigger!!! You only try to insert the record and bring an error if it fails. Greetings, Frank

It may be bug (or better “unexpected behaviour”) in RecordRef and FieldRef (3.60). RecordRef.Open should also return Ok (or not) according to documentation, but it allways returns false.

This is true Robi… FieldRef.Validate always returns false…!?! that was the main reason of this post. It might be a bug or we doing something wrong. Philip, I was trying to avoid that but it seems to be the only solution. :slight_smile: Thanks for your replies.