02-13-2012 07:26 PM
I have been implementing validation for required fields by attaching to the entity OnBeforeInsert and OnBeforeUpdate events. In the validation code, I check the required fields and raise the Sage.Platform.Application.ValidateExecption if any issues are found. This works well in general - when a required field is left blank, the insert/update is cancelled and a message box is shown to the user with the exception message.
The problem I am having is with the built-in move/copy contact function. When copying a contact, the built in function does not copy custom contact fields (i.e. fields I have added to the Contact table & entity, one of which is a required field). As a result of this, the copy function is always blocked by the validation exception.
I've tried adding logic to the post-execute step of the built-in MoveContact business rule to copy my required fields. However, this comes too late - the contact OnInsert event is called before the MoveContact post-execute step runs, and the damage is done. If I remove my validation, this works for getting my required field populated, but (of course) I'd like to leave my validation in place.
All suggestions are welcome (although I'm really hoping I don't have to change my general approach, and really really hoping I can stay with entity level validation and not have to start attaching validation logic to each UI form).