//Info: CDUS-2259
The Make default field under the credit card information tab in the external customer payment record is checked while creating a payment. It is noted this field is disabled in Transaction forms as well as not accessible in the workflows. We set this field as unchecked and set it to Hidden so that no user can regenerate the issue in the future.
const beforeLoad = (scriptContext) => {
try {
if (scriptContext.type === scriptContext.UserEventType.CREATE ||
scriptContext.type === scriptContext.UserEventType.COPY) {
var customRole = runtime.getCurrentUser().role
var currentRec = scriptContext.newRecord;
// Checking User Role
if (customRole == 1030 || customRole == 1017 || customRole == 14) {
var form = scriptContext.form;
var customer = currentRec.getValue({
fieldId: 'customer'
})
var ccDefault = form.getField({id: 'ccdefault'});
ccDefault.updateDisplayType({
displayType: serverWidget.FieldDisplayType.HIDDEN
});
if (ccDefault) {
var newstRec = currentRec.setValue({
fieldId: 'ccdefault',
value: false,
ignoreFieldChange: false
});
}
}
}
} catch (e) {
log.debug('error', e);
}
}
return {beforeLoad}