We have previously created a COM-script for one of our customers that validate different fields on a contact before they are allowed to save.
The script looks like this:
If CurrentContact.Identity = 0 Then
if (CurrentContact.Category.Id = 0) then
CurrentContact.ValidationMessage = "Du må sette en kategori"
CurrentContact.ValidationMessage = ""
If CurrentContact.Category.Id = 3 OR CurrentContact.Category.Id = 12 Then
validationMessageContact = 0
First i check if this is a new contact, then i first validate if they have set a category.
The rest is pretty much the same as above, i validate postal-fields, business, phones and email if the category is of id 3 or 12. I have created Subs for all the individual fields and just call the sub from the event as shown above.
This works as it should, the save-button is disabled as expected, but the client is 'laggy' when i input anything in a field.
This is 100% because of our script and im not sure if there is a better way of solving this.
As far as i know i cant prevent an actuall save in the BeforeSaveContact-event, i can only route the user back to the same contact in edit-mode.. I dont want the contact to be saved at all unless these fields are filled out.
There is no other scripts running on contact so its only this code that makes the COM-client laggy.