Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

CRM Plugins For Related Entities

Posted on by 65

Dears,

How to run plugin for parent entity  AFTER Updating field in the child entity through plugin 

Example : 

I have Order , Order details entities. 

there is a plugin running in details which update the total field in the header, after updating the header total there is a plugin to some the Total Order . 

the parenet plugin giving error.

how to impleement this scenario ?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM Plugins For Related Entities

    Hi Jesri,

    As per my understanding, you want to update the total in order based on totals in Order details. You have two plugins 1st plugin calculates and updates Order detail’s total field and on the change of total field, you update the Parent order total field.

    My Suggestion: Instead of two plugins make it one. If you cannot do that then run your plugin on update/Change of total field in Order details. Fetch parent’s Order details records using fetchxml it might be like the below screenshot.67241.png

    Replace Parent order with your running order detail’s parent order.

    And retrieve those records using service.retriveMultiple.

       var orderDetails = service.RetrieveMultiple(new FetchExpression(fectXml));

     

    here you have a list of all Order details list with parent Id.

    Then calculate and Update whatever field you want in Order or Order Details.

    Note: you already get the parent Order form running order details.

    For further details, you can go through Microsoft documentation

    Docs link: Entity Operations using the Organization service (Microsoft Dataverse) - Power Apps | Microsoft Docs

    For further queries visit:  https://www.solzit.com/ 

    Regards,

    Kirti

  • Suggested answer
    RE: CRM Plugins For Related Entities

    Hy Jasri- We have faced a similar scenario on Opportunity and opportunity products. We have achieved the functionality by firing a plugin on Opportunity product entity. Our scenario was related to update. In this context we got an opportunity id and then we need to retrieve the opportunity and update the desired field on opportunity entity.

    Just make sure you put the context. Depth check if there is any scenario in which you are facing any infinite loop issues.

    These related entities in OOB become sometimes weird to handle.

    If this answer helps you out, please mark this answer verified.

    Thanks,

    Ankit Sabharwal

  • AlxKpk Profile Picture
    AlxKpk 10 on at
    RE: CRM Plugins For Related Entities

    If you need to run your plugin on a parent record you have to trigger a plugin message (Update, Associate, SetStateDynamicEntity, etc.) on the parent record at least.

    In general I would suggest to trigger both plugins for the Order Details entity as both processes (update total field, summarize total fields) are triggered on the same entity.

    For further questions please also provide the exception details.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans