Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Pluign Execution

(0) ShareShare
ReportReport
Posted on by 465

Hi Everyone.

We have one pluign1 which triggers on Create event of "CD" entity.
Inside this pluign we updating the target "CD" record... (we are processing some complex logic, that's the reason we are updating it inside pluign, we can't change this now)

We also have plugin2 which triggers on Create & Update event of "CD" entity and running in async mode.
Inside this plugin we creating the "RD" record(child record of "CD").

Issue is, pluign2 creating 2 RD records on create of CD record.
To avoid this:
In pluign2, we have one condition of "if (context.Depth > 1) return;"
In pluign2, we also check the if RD is already exist(via fetchxml) - if NO then only we are creating RD record. This check is not working as it should. We found in trace that, "RD already exist" code doesn't found any record. What would be the reason?

*This post is locked for comments

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Pluign Execution

    Any specific reason you have plugin 2 as Async. Did you try changing Plugin to to Sync or Plugin 1 to Sync (i.e. keeping it same for both).

    Also, check if you can set attribute filtering for your Plugin 2 update step so that it trigger only when it needs to. 

  • ChangeFrenzoId Profile Picture
    ChangeFrenzoId 465 on at
    RE: Pluign Execution

    Thanks Ravi. You are right. And yes, facing this even if i use depth. Have ordered CREATE step to 1 and UPDATE step to 99. Do you know any way to fix this?

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Pluign Execution

    Hi Piyush ,

    Did you set the execution order in your plugins ,if not then set the order  , make sure you are checking the child records in the plugin should be  post create operation and both plugin should be asynchronous.

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Pluign Execution

    Hi,

    If I am not wrong the reason you are not able to find the new created record is because the record is not committed yet to the database as plugins runs in transaction. Are you getting this issue even with the depth check?

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: Pluign Execution

    1. CD record created

    2. A post create plugin1 updates the same target record

    3. A post create & update plugin2 will trigger on both scenario above & create RD record - so duplicates; depth check to stop it

    4. Check RD record exists using fetchxml - if yes then create again??

    Suggestion:

    If 1 & 2 going to happen sequentially at any cost, register plugin2 only in update or create. So no need of depth & check. Hopefully every single problem will be solved.

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,014 Super User 2024 Season 2 on at
    RE: Pluign Execution

    Hi Piyush Parate,

    Are you able to post the code for the Plugins?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans