Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Plugin Execution

Posted on by Microsoft Employee

Need Clarification on below scenarios. I want to understand plugin execution. Please help.

  1. Scenario1:  If you have Asynchronous plug in, which is registered for “post operation” stage. This plug in have logic to Create CONTACT record after ACCOUNT record is created. Now if there is any error while creating CONTACT record, what will happen?  Will it rollback the ACCOUNT record also?
  2. Scenario2: same as above but for Synchronous plug in what the result it would be?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin Execution

    If you look at post operation in below link you would see that plugins written at this stage execute within the DB transaction. So I guess, account will be rolled back too.

    msdn.microsoft.com/.../gg327941.aspx

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin Execution

    Scenario 1 will not rollback. Is like an async workflow. Each operation is executed separately.

    Scenario 2 will rollback. Those are group under the same DB transaction.

    Post-Event

    Post-operation

    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.

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Plugin Execution

    Hi Monika,

    Sorry, I was mistaken. Actually, the post-operation stage executes after changes have been committed to the database. So the account record will be present in DB in Scenario 2.

    If it was registered in the pre-operation stage, the account record will not be present in DB in Scenario 2.

    See: http://crmbook.powerobjects.com/extending-crm/plug-in-development-and-workflow-extensions/plug-ins/event-pipeline/

    Event processing architecture

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin Execution

    Hi Nithya,

    Thanks for your reply.

    I am bit confused now for second point that plugin is synchronous and post stage plugin means account already created in DB now plugin triggered and creating Contact record. so still it will rollback of account record too? i am clear with Pre - operation and synchronous plugin that account record will not be created. Please clarify.

    Also, could you please elaborate Plugin Transaction in depth.

    Thanks you in Advance!

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Plugin Execution

    Hi Monika Jain,

    Scenario1: Since it is an asynchronous plugin, it allows triggering event to finish before the plug-in code runs. So the account will be created and contact will not get created if an error occurs while contact creation. The account record will be present in DB.

    Asynchronous plug-ins are executed by asynchronous service. Asynchronous plug-ins allow triggering event to finish before the plug-in code runs. Therefore these can never be used to prevent an action, validate data entry, or provide any error messages back to the user.

    Scenario2: Since it is synchronous plugin, triggering event will wait until the plug-in finishes the execution. So the error in plugin code while contact record creation will not create the account record too. The account record will not be present in DB.

    Synchronous plug-ins are executed by the CRM Core System. Synchronous execution means that triggering event will wait until the plug-in finishes the execution. For example, if we have the synchronous plug-in that triggers on the creation of account and user creates account record in CRM, the form will hang at saving until the plugin has finished.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin Execution

    Agreed! for the point 1.

    but for point 2 - plugin is triggered only once Account record gets created. now plugin transaction gets started. if then some exception occurs during creation of Contact then contact record should not create but account record will be present in database na?

    Please suggest!

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin Execution

    Here's what I think

    1. Account will not rollback only the actions done by the plugin will rollback. Async plugins have a separate transaction.

    2. Account will also rollback.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans