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 ?
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.
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
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
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156