if (newRecord.type === record.Type.SALES_ORDER) {
let status = newRecord.getValue({ fieldId: ‘status’ });
log.debug(‘status’, status);
try {
// Check if the Sales Order status is ‘Billed’
if (status === ‘Billed’ && scriptContext.type === scriptContext.UserEventType.VIEW) {
// Hide Edit button by making the form read-only
let form = scriptContext.form;
let editButton = form.removeButton(‘edit’); // Disables all buttons, including the Edit button
}
} catch (e) {
log.error(‘error’, e);
}
}