Cory Weiner
06/22/2022, 2:45 PMJoe Thomson
06/22/2022, 2:59 PMdoesCustomerExist = (customerId) => {
if (!customerId) { return false; }
try {
let recordObj = record.load({ type: record.Type.CUSTOMER, id: customerId });
return true;
} catch (er) {
log.debug({ title: '', details: er.message });
return false;
}
}
This is something that comes on the top of my head. I ain't sure that this is the best method. This throws an error, however the error is caught on the catch() and returns false if a record doesn't exist. It should cost you 5 units.ehcanadian
06/22/2022, 4:00 PMZoran R-DATAGRAM
06/22/2022, 8:08 PMJoe Thomson
06/23/2022, 1:29 PMZoran R-DATAGRAM
06/23/2022, 3:22 PMrequire(['N/record'],function(rec) {
rec.load({
"type" : 'invoice',
"id" : 5723
});
}
)
response, executed in Script Debugger with ROLE with Invoice->View Permission
{
"type": "error.SuiteScriptError",
"name": "INSUFFICIENT_PERMISSION",
"message": "Permission Violation: You need the 'Transactions -> Invoice' permission to access this page. Please contact your account administrator.",
"stack": [
"createError(N/error.js)",
"<anonymous>(adhoc$-1$debugger.user:3)",
"<anonymous>(adhoc$-1$debugger.user:1)"
],
"cause": {
"type": "internal error",
"code": "INSUFFICIENT_PERMISSION",
"details": "Permission Violation: You need the 'Transactions -> Invoice' permission to access this page. Please contact your account administrator.",
"userEvent": null,
"stackTrace": [
"createError(N/error.js)",
"<anonymous>(adhoc$-1$debugger.user:3)",
"<anonymous>(adhoc$-1$debugger.user:1)"
],
"notifyOff": false
},
"id": "",
"notifyOff": false,
"userFacing": false
}
Zoran R-DATAGRAM
06/23/2022, 3:33 PM