Question: Within SalesLogix I have created a custom business rule that needs to be executed before saving a record. If that custom rule fails I would like to display a custom message to the user explaining why it has failed to save. So far, I have added a C# code snippet to the BeforeInsert or BeforeUpdate Event that produces a new ApplicationException if that business rule fails. The record won’t save, which is what I want, but the message that pops up is confusing to the user:
‘An exception occurred executing the dynamic method Ticket.OnBeforeInsert.’
Is there a way that I can create a custom exception message to display to the user?
Answer: To do this you will need an optional message as a parameter. Here is an example:
throw new Sage.Platform.Application.ValidationException(“Field xxx is required.”);
This pops a java alert box with your message to the user and halts execution of the save.