{
var sysstatus=formContext.getAttribute(/msdyn_systemstatus/);
var sysstatusvalue=Xrm.Page.data.entity.attributes.get(/msdyn_systemstatus/).getText();
var error='N';
// get WO GUID
var workorderId = formContext.data.entity.getId().replace('{', '').replace('}', '');
//get WR records
if (sysstatusvalue==='In Progress') {
await Xrm.WebApi.retrieveMultipleRecords(/vel_workreport/, fetchXml).then(
function success(result) {
alert(/wr_count variable is / + wr_count);
//check system status and wr count
if (wr_count ===0 )
{
alert(/ There are no Work Reports. Please enter Work Reports for the job before closing/)
executionContext.getEventArgs().preventDefault();
},
function (error) {
alert(/error/);
}
);
}
}
}