In Microsoft Dynamics CRM 2011 it is possible to pull data from a sub-grid on a parent form when a page loads to read the values.

Place the script below inside a Web Resource and call the function "calcPortfolio" on a "OnLoad" event.

function calcPortfolio() { var portAmount = 0.00; //name of the sub-grid var gridControl = document.getElementById("SubGridName").control; var ids = gridControl.get_allRecordIds(); for(i = 0; i < ids.length; i++) { var cellValue = gridControl.getCellValue('SubGridField', ids[i]); // cellValue has a datatype of Currency cellValue = parseFloat(cellValue.replace(/[$,]+/g,"")); portAmount = portAmount + cellValue; } var Name = Xrm.Page.data.entity.attributes.get("fieldOnParentForm"); Name.setValue(portAmount); }
Posted in:

Start a Project With Us

Submit your email below to get in touch with our team.