// This JavaScript code is used to control the Submitted Date field. There should not be a submitted date if the claim status is Saved or Incomplete

function date() {

    var submittedDate = window.parent.Xrm.Page.getAttribute("btsss_submitteddate").getValue();//get value of the Submitted Date field
    var status = window.parent.Xrm.Page.getAttribute("btsss_status").getValue();//get value of the Claim Status field

    if (submittedDate == null) {
        if (status != '421750007') { // status is not Incomplete
            if (status != '421750000') { //status is not Saved
                var time = new Date();
                window.parent.Xrm.Page.getAttribute("btsss_submitteddate").setValue(time); //sets the date and time in Submitted Date field
            }
        }
    }
}

