
Hello, I'm trying to sum all register from a column from a Subgrid using a Javascript, I'm not really sure if Im doing correctly because the code is not working and also I added the event handler
on the new field I added to show the value of the Sum but this handler only works on onChange I can't add the event on the subgrid, if anyone can point me in the right direction , this is my code.
function totalHours(executionContext)
{
debugger;
var formContext =executionContext.getFormContext();
if (formContext.getAttribute("Visit_Times").getValue() != null)
{
var count = formContext.getControl("Visit_Times").getGrid().getTotalRecordCount();
for(i = 0; i < count; i ) {
var gridControl = formContext.getControl('Visit_Times').getGrid().getRows().get(i).getData().getEntity().getAttributes().get('Onsite time').getValue();
var cellValue = gridControl;
cellValue = cellValue.replace( /,/,"." );
var sum = sum parseFloat(cellValue);
}
}
formContext.getAttribute('new_TotalOnSite').setValue(sum);
}
I'm not really sure in which part I'm making the mistake.
Thank you.
Kind Regards,
Jorge.
Hi JorgeDiaz,
Please refer to this thread: Total amount of a dynamic filtered data in a sub-grid - Dynamics 365 General Forum Community Forum
This thread has a similar demand as yours and I provide the code sample to achieve this. You could have a try with that.