Hello all, please consider this scenario:
I have two entities, A and B with a N:N relationship between them.
On A form I have a read-only subgrid where the user can add/remove B records, triggering a plugin on server side for the associate/disassociate event.
This plugin reads the Value field from all the B records currently associated with A and sums it, updating the read-only field TotalValue from A present on the same form the user is making the changes.
My issue is that the change is not being reflected to the form, where the TotalValue shows the old value until the user refreshes the page.
On the client side I have an onLoad event for the subgrid that calls a script, where I'm trying to read the Value from all the B entities and update the TotalValue field on the form, but since my subgrid is read-only I can't call getAttribute on it to read this value.
I know I have some options, but I have a down side for them, like:
Forcing form refresh with formContext.data.refresh() - I don't want to save/ignore the changes of the whole form all the time the user makes a change on the subgrid (I'm also not using auto save)
Fetch the values with Xrm.WebApi.retrieveMultipleRecords() - This sounds like my last reasonable option, but since the B entities were already loaded to the grid and the Value is being shown on the grid, I can't stop thinking that must be a easier way to do that.
Any ideas to this scenario that I am missing?
Thanks.