<body>
<img src="https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Mu3b?ver=5c31" alt="">
<div >
<label for="Actual Date">Actual Date</label>
<input type="text" id="Acutal Date">
</div>
<br>
<div>
<label for="Planned Date">Planned Date</label>
<input type="text" id="Planned Date">
</div>
</body>
<script>
window.onload= load;
function load(){
//Get the Actual Date and Planned Date in an HTML web resource.
var actualDate = window.window.document.getElementById("Acutal Date");
var plannedDate = window.window.document.getElementById("Planned Date");
//Gets all row records of the case subgrid.
var gridControl = window.top.Xrm.Page.getControl("contactcasessgrid");
var gridRows = gridControl.getGrid().getRows().get();
//If no row records are fetched, wait 4 seconds for the case subgrid to finish loading to execute the next step.
if(gridRows.length ===0){
setTimeout(function(){
//Iterate through all rows of records
for(let item of gridRows){
//Look for the record for Warranty Type as simple.
let type = item.getAttribute("cra21_warrantytype").getValue();
if(type !== null&&type===0){
//Populate the HTML web resource with the values of Actual Date and Planned Date for records with a Warranty Type of simple.
actualDate.value = item.getAttribute("cra21_warrantyactualdate").getValue()
plannedDate.value = item.getAttribute("cra21_warrantyplanneddate").getValue()
}
}
},4000);
}
}
</script>