Hi I would like to ask. why the following javascript not sum up when I apply into my crm2011??
function subGridOnload() { var grid = Xrm.Page.ui.controls.get('attachmentsGrid')._control; var sum =0.00; if (grid.get_innerControl()==null) { setTimeout(subGridOnload, 1000); return; } else if (grid.get_innerControl()._element.innerText.search("Loading")!= -1) { setTimeout(subGridOnload, 1000); return; } var ids = grid.get_innerControl().get_allRecordIds(); var cellValue; for(i = 0; i < ids.length; i++) { if (grid.get_innerControl().getCellValue('filesize', ids[i]) !="") { cellValue = grid.get_innerControl().getCellValue('filesize', ids[i]); alert(cellValue); //cellValue = cellValue.substring(2); //cellValue = parseFloat(cellValue); sum =sum + cellValue; } } alert(sum); }
The script is to retrieve the size of attachment in a subgrid.
But the alert message prompted and not show the total sum. Please Help.
HI, how to retrive all rows from SUBGRID using Jscript
i have one entity "E-mail" which contain one subgrid "attachmentsGrid"
now i need to retrive all the attachment size and total it up then show in a field....
Hello,
You need to query the source entity in sub grid so for example you can check annotation, you can query it based on regarding object id.
Microsoft Dynamics CRM Training|Our Blog | Follow US | Our Facebook Page | Microsoft Dynamics CRM 2011 Application Design Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.
Though I have not tried it but ExecuteByIdSavedQueryRequest might help you.
You should be able to query data for given view of subgrid.
Reference on: ExecuteByIdSavedQueryRequest
http://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.executebyidsavedqueryrequest.aspx
Sample:
http://msdn.microsoft.com/en-us/library/jj863623.aspx