|
Jul 26
2011
|
How to pull data from a sub-grid on a parent form in MSCRMPosted by: Administrator in MyBlog Tagged in: Microsoft Dynamics CRM
|
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);
}







