Posts

Showing posts with the label plugins

CRM 2011 Plugins: Welcome to transactions !

One of the thing I hate about CRM 4.0 plugins is the inability to automatically rollback actions when an exception occurs during a business process. To illustrate this, imagine a plugin which creates a contract, then a line of contract. If the code throws an exception during the creation of the contract line, you need to take care yourself of deleting the contract that have been created: of course, you need the contract AND the contract line, not just the contract. In CRM 2011, you can now register your plugin in new stage (see below). That means that you can register your plugin in a transaction (if using stage 20 and 40) and whenever you plugin throws an exception, every action done during the transaction will be rollback. In our previous example, that means tha the contract will be deleted automatically by the application. Event Stage Name Stage Number Description Pre-Event Pre-validation 10 Stage in the pipeline for plug-ins that are to execute before the main system...

Plugins and update record state: Do I have to use message SetState or SetStateDynamicEntity

One question that came to me while I had to develop a plugin when record state changed... The answer is quite simple if you understand how the CRM application communicates between the presentation layer and data access layer. In fact, all communications between the forms and the data access layer seem to be in the form of DynamicEntity. So when you change the status of a record via the forms, or when you use the SDK class SetStateDynamicEntityRequest, you register your plugin on the SetStateDynamicEntity message . If you use in your code SetStateAccountRequest class (for example), you must register your plugin on the SetStage message.