//Info:APCN-214
Instead of applying to every record, we may need to add buttons to record pages that only apply to specific statuses such as Open, Processing, and so on.
In this case, we created a Button to Quote record that will appear only if the status is not Voided & Expired.
const beforeLoad = (scriptContext) => {
if(scriptContext.type=="view" ) {
try {
var qoRecord = scriptContext.newRecord.id;
qoRecord = record.load({type: record.Type.ESTIMATE, id: qoRecord, isDynamic: true})
var status = qoRecord.getValue({fieldId: 'status'});
if (status !== 'Voided' && status !== 'Expired' ) {
scriptContext.form.addButton({
id: 'custpage_downloadexcel_button',
label: 'Download Excel',
});
}
}catch (err){
log.debug('error',err)
}
}
}
return {beforeLoad}