Hi,
Trying to accomplish the following logic on Edit page.
- If PMReview is changed to 'Yes' then: Set PMReviewDate = today() and Make both PMReview and PMReviewDate readonly.
- If record already has the value PMReview ='Yes' then: Make both PMReview and PMReviewDate readonly.
Step 1 works, but I cannot find a way to make the fields readonly if the PMReview value is already set to 'Yes'.
var ctrlPMReview = Runner.getControl(pageid, 'PMReview');
var ctrlPMRDate = Runner.getControl(pageid, 'PMReviewDate');
ctrlPMReview.on('change', function(e) {
if (this.getValue() == 'Yes') {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd = '0'+dd
}
if(mm<10) {
mm = '0'+mm
}
today = mm + '/' + dd + '/' + yyyy;
ctrlPMRDate.setValue(today);
ctrlPMRDate.makeReadonly();
ctrlPMReview.makeReadonly();
}
else
// I have moved this code to above the onchange test and removed the else - doesn't work either.
// PMReview already Yes - no onchange event.
if (ctrlPMReview == 'Yes') {
ctrlPMRDate.makeReadonly();
ctrlPMReview.makeReadonly();
}
});