locked
Can any body give an example for when to use preImage, Post Image, preValidation, Post validation events? RRS feed

  • Question

  • Hi Techies,

    I have been looking in web for a very good example with a simple scenario when to use the below

    Images:

    PreImage

    PostImage

    Events:

    PreValidation

    PostValidation

    And also when to choose custom workflow over plugin? and why to choose the one over other?

    Thanks in advance


    Sreeni Pavalla

    Tuesday, June 3, 2014 5:26 PM

All replies

  • Hi Sreeni,

    Please refer my answer below..

    PreImage Entity/Post Entity

    PreEntityImages and PostEntityImages contain snapshots of the primary entity's attributes before and after the core platform operation. Microsoft Dynamics CRM populates the pre-entity and post-entity images based on the security privileges of the impersonated system user. You can specify to have the platform populate these properties when you register your plug-in. The entity alias value you specify during plug-in registration is used as the key into the image collection.


    Consider following scenario :

    we want to update phone number on all contact records when parent account phone number gets changed,  for this you will create plug in Post Account Update and retrieve pre Image and Post Image and check if telephone number fields is changed then write method call which will retrieve all contact for this account and update them.

    With out pre and post image you will not able to achieve this as you need to know which fields are changed and then perform relevant operations..


    PreValidation Event

    Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage may execute outside the database transaction. The pre-validation stage occurs prior to security checks being performed to verify the calling or logged on user has the correct permissions to perform the intended operation.

    PostValidation (Stage 40)

    Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.


    PostValidation (Stage 50)

    Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage may execute outside the database transaction. This stage only supports Microsoft Dynamics CRM 4.0 based plug-ins.


    Read following two links and it will answer your questions related to when to use workflow or plug in 

    http://blogs.msdn.com/b/crm/archive/2010/06/25/plug-ins-vs-workflows-in-microsoft-dynamics-crm.aspx
    http://msdn.microsoft.com/en-us/library/dd393303.aspx

      

    MayankP
    My Blog
    Follow Me on Twitter

    Tuesday, June 3, 2014 8:06 PM
    Answerer