Description : We need to activate a checkbox based on the payment done on the website as credit card.
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record'], function (record) {
function beforeSubmit(context) {
if (context.type !== context.UserEventType.CREATE ) return false;
var checkboxValue;
var newRecord = context.newRecord;
// Retrieve the field values
var fieldValue = newRecord.getValue({
fieldId: xxxx // Replace 'your_field_id' with the actual field ID to check its value
});
//Perform the logic based on the field value
if(fieldValue==='1'){
checkboxValue=true;
}else{
checkboxValue=false;
}
// Set the checkbox field value
newRecord.setValue({
fieldId: xxxx, // Replace 'your_checkbox_field_id' with the actual checkbox field ID
value: checkboxValue
});
}
return {
beforeSubmit: beforeSubmit
};
});