The checkbox was checked during the record creation, and when record is edited then it should be disabled.
In User Event Script, beforeLoad(scriptContext) entry point is used. It has scriptContext.form as a parameter.
const beforeLoad = (scriptContext) => {
try {
let oldRecordCheckbox = scriptContext.newRecord;
let checkboxOld = oldRecordCheckbox.getValue({
fieldId: 'fieldId' //get the checkbox value from the record.
});
let form = scriptContext.form;
let checkboxId = form.getField({
id: 'id' //fieldId of the field to be disabled.
});
if (scriptContext.type == 'edit' && checkboxOld == true) {
checkboxId.updateDisplayType({
displayType: serverWidget.FieldDisplayType.DISABLED
});
}
}
catch (e) {
log.error("error@beforeLoad", e)
}
}