Andrew Beard Andrew Beard
03/25/2024, 8:34 PMfunction afterSubmit(ctx) {
const log_ = {
start: Date.now(), ueType: ctx.type, exeCtx: runtime.executionContext,
};
let id = ctx.newRecord.id;
if (createApproveOrEditInUIOrWebService(ctx)) {
try {
ctrl.autoProcessOrder(id, log_);
}
catch (err) {
log_.error = err;
}
}
log_.end = Date.now();
log_.time = log_.end - log_.start;
if (log_.error) {
log.error({ title: `Error Auto-Process ${id}`, details: log_ });
}
else {
log.audit({ title: `Auto-Process ${id}`, details: log_ });
}
}
function createApproveOrEditInUIOrWebService({ type, UserEventType }) {
const { executionContext, ContextType } = runtime;
let creating = type === UserEventType.CREATE,
copying = type === UserEventType.COPY,
approving = type === UserEventType.APPROVE,
editing = type === UserEventType.EDIT,
inUI = executionContext === ContextType.USER_INTERFACE,
webServiceCall = executionContext === ContextType.WEBSERVICES;
let validUEType = (creating || copying || approving || editing),
validExeCtx = (inUI || webServiceCall);
return validUEType && validExeCtx;
}
Stefan Reeder
03/26/2024, 2:19 PMStefan Reeder
03/26/2024, 2:24 PM