CRM 2011 Plugin Template

Here is the template to get you started on plugin development in CRM 2011:



To get the service context of your organisation :


Important Notes:

PRE PLUGINS
  • You don't need to call SaveChanges because the entity can be updated before it is saved into database.
  • For pre-update, entity will only have attributes that are changed. To get the other attributes that don't change, you can query those attributes using the service context.

POST PLUGINS
  • You need to call SaveChanges because the entity has been saved into database.
  • Entity will have all updated attributes when retrieved using service context.
  • When doing the post update of an entity that update the same entity attributes, loop will occur. To avoid this you can use context.Depth to check the loop count.

OTHERS
  • For delete message, the context.InputParameters["Target"] is an EntityReference instead of Entity.
  • You can check the context message using context.MessageName

Hope this helps,
Andreas

Post a Comment