How do I perform conditional validation on a form?

Hi,

I need to perform conditional validation on a field. For instance, if FIELD1 on a table is ‘ABC’, then I would like to validate FIELD2 on the same table?

Should I try to override the below method on the Datasource field of the form as shown below? If yes, how should I perform the conditional validation?

public boolean validate()

{

boolean ret;

ret = super();

return ret;

}

Thanks,

Kumar

You could use the validateField on the Table itself.

Use the switch statement to see which fieldId is passed through.

This method is only called from the UI, when the field value has been changed.

If you want the validation to occur before saving the record, then use the validate method on the Table method, or the datasource table method (Only use the method on the field only if needed when the other methods cannot be used for the same)

For your case, i would use the Validatewrite method on the Table itself (not the form)

This will be called everytime the record is saved, irrespective if the fields was changed or not.

If you want to validate only when the field changes, tehn you can compare the value to the _orig record to check if it has changed and then perform the validation.

Thanks Shashi. Placing the logic on validatewrite worked!