hi
What would be the best way to update a parent table field if a subgrid on the form had been added to?
The relationship is N:N
Thanks
hi
What would be the best way to update a parent table field if a subgrid on the form had been added to?
The relationship is N:N
Thanks
In the Form you have to check "Pass execution context as first parameter"
from the docs, about addOnLoad
"The function to be executed when the subgrid loads. The function will be added to the bottom of the event handler pipeline. The execution context is automatically passed as the first parameter to the function. See execution context for more information."
So basically you'll have
function myContactsGridOnLoadFunction(executionContext){ let formContext = executionContext.getFormContext() let hiddelField = formContext.getAttributes('fieldname').getValue() }
How do I use executioncontext with this in order to update the fields?
I mean in that I need to refresh the subgrid, then tell it to calculate the difference between the hidden count field and the calculated field after I've refreshed the grid.
gridContext.addOnLoad(myContactsGridOnloadFunction);
For this example I would need executioncontext in myContactsGridOnloadFunction
Thank you, but the development has already been done for this, I'm just stuck trying to make the flow work.
Hi,
You will use plugin on Associate message to update field on parent entity.
I don't think you can trigger Power automate/Classic Workflow when record added in N:N relationship,
However you can trigger Power Automate/Classic Workflow when you use Custom N:N relationship instead of using OOB N:N relationship .
More details on Custom N:N - global.hitachi-solutions.com/.../custom-entities-n-n-relationships-dynamics-365-customer-engagement
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
the flow is currently set to trigger whenever the parent is updated. However it does nothing if the subgrid hasn't got additions.
by counting the records it could be an issue if one gets deleted at the same time.
Remember that the onload Event is called also when the subgris is refreshed, so for example, also when you just load the parent form.
My idea is that you could use an hidden variable with the number of subgrid record. When the onload event fire, you can retrieve the records and see if the total is one more than the value in the hidden variable. If so, you can update that number and trigger the flow
Brilliant
So if I effectively used the code to update the "modified on" date field, it should trigger the flow?
Yes, it works also if a record is added to the subgrid, because it cause the refresh of the subgrid itself
Thank you, would this work whenever the subgrid is added to? (it's not an issue if it does it every time).
Basically I've got a Power automate flow that needs triggering whenever the subgrid is added to, so need something that will amend a hidden switch on the parent table
You can use the gridContext.addOnLoad(myFunction), using it in your js file. Everytime a record is added to the relative subgrid or any value is changed, the relative function will be call. But remember that it will fire also if you refresh manually the subgrid or if you sort the columns
André Arnaud de Cal...
293,278
Super User 2025 Season 1
Martin Dráb
232,011
Most Valuable Professional
nmaenpaa
101,156
Moderator