SBarnes wrote:Is there a way to add validation to a custom field on a debtor for instance if the custom field was a phone number where it was required to start with +61 or that the field contained the necessary elements to be an email address?
You can use the ErrorText property of the grid cell to display an error indicator with a tooltip indicating the problem:
- Code: Select all
grid.ActiveSheet.Cells(Row, grid.ActiveSheet.GetColumnFromTag(null, "RemitNo").Index).ErrorText = "This is my error";
You can do this within the PropertyChanged handler of the custom field values collection of the object - you'll just need to iterate the grid row by row to find the right row with the custom field name or id corresponding to the one in the event parameters.
You can then also add a client cancelled exception on the Savestart event of the business logic to cancel saving if any custom field value is not expected / valid.
You could also add edit masks to the grid cell - to force things like numeric only input - but I'm not a huge fan of that approach - I prefer to display an error indicator instead.