I have a plugin registered on Pre-Create of a Service Activity. In the plugin I check some conditions and if they are met i want to stop creating the service activity. Instead of that service activity I want to create two other that will be a replacement. But I don’t want the user to be notified for all this.
Is there a way to stop the creation of the SA record in a plugin on CRM 2011?
So, If a user triggers the creation of the service activity via the Dynamics CRM GUI, the form is normally saved (by sending an internal
UpdateRequest), then refreshed via another trip to the database. If you deleted the record in between the two events via a plugin, the user will certainly be notified by the standard “Record can’t be found” error message. In this case, throwing an exception in the plugin preventing the creation of the record is equivalent in that the user will be notified, but at least he’d see a customizable message perhaps telling him why the save didn’t work.It would seem to me the best way to handle this via a plugin is to
If you have control over the GUI, you can do things a little differently (delete the record post operation, for instance, though this would still result in one additional and unnecessary database operation), and you can always use javascript for client-side validation.
One more point: I must also add that from a user’s perspective, saving a record and then not seeing it immediately would constitute an unexpected CRM behavior. If something like this happened, I would at least expect to receive either some training on how that section of the CRM works or a notification that something fundamentally different has in fact happened.