I am hoping someone can shed some light on my problem. I am using the OOTB entity "CASE", I have a customer entity called "SAMPLE". One Case can have many Samples.
On the case form I have a field called "Sample Count". The following code calculates the number of records in the subgrid on the case form and adds the value into the Count Field.
I have this code called "onSave" and "onLoad" of the case form.
However, my issue is the sample count does not seem to calculate onload, It updates instantly when I save the case form.
In my case this is not sufficient, for example if I create a sample from a case and then save and close the sample...I come back to the case form BUT I need to save before the count is correct.
function CountNumSamples() { if (document.getElementById('Samples')!= null) { var count=document.getElementById('Samples').control.get_totalRecordCount(); var x = parseInt(count); Xrm.Page.getAttribute("samplecount").setValue(x); Xrm.Page.getAttribute("samplecount").setSubmitMode("always"); } else { setTimeout("CountNumSamples()", 1000); } }