Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

JavaScript Fires too fast. Objects not loaded

$
0
0

I have the below JavaScript running on one of my forms OnLoad event :-

function calcServicePriceTotal() {

var grid = document.getElementById('ProjectServicesGrid'); 
var ids = grid.control.get_allRecordIds();
var sum = 0.00;
var cellValue;

for(i = 0; i < ids.length; i++) {

	var cellValue = grid.control.getCellValue('iss_salesprice',ids[i]);
	var number = Number(cellValue.replace(/[^0-9\.]+/g,""));
	sum = sum + number;
}
Xrm.Page.data.entity.attributes.get("ava_tempgrossvalue").setValue(sum);
} 


Unfortunately I get the following error :- 

"Error:'subGridOnload' is undefined"

I believe that the script is firing before the object has had the time it needs to load so what can I do to slow down the function? There must be some way to overcome this but I am far from a JavaScript expert so I could use some help.

Thanks in advance 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>