Customization › Scripting
Script Debugger
Paused at a breakpoint in SuiteScripts/huzzle/hz_so_approval_ue.js · user event on Sales Order SO10142 · session 4f21-a09c
Execution log PausedUsage remaining 873
SuiteScripts/huzzle/hz_so_approval_ue.js
Line 24
1/**2 * @NApiVersion 2.13 * @NScriptType UserEventScript4 * @NModuleScope SameAccount5 * Wexbourne ERP — sales order approval routing6 */7define(['N/record', 'N/search', 'N/runtime', 'N/log'], (record, search, runtime, log) => {89 const TIER_LIMITS = { rep: 5000, manager: 25000, director: 100000 };1011 const getApprovalTier = (total, subsidiary) => {12 const multiplier = subsidiary === 2 ? 1.15 : 1;13 if (total <= TIER_LIMITS.rep * multiplier) return "rep";14 if (total <= TIER_LIMITS.manager * multiplier) return "manager";15 return "director";16 };1718 const beforeSubmit = (context) => {19 if (context.type === context.UserEventType.DELETE) return;2021 const so = context.newRecord;22 const total = Number(so.getValue({ fieldId: "total" })) || 0;23 const subsidiary = so.getValue({ fieldId: "subsidiary" });24 const tier = getApprovalTier(total, subsidiary);2526 const customer = so.getValue({ fieldId: "entity" });27 const onHold = search.lookupFields({28 type: search.Type.CUSTOMER,29 id: customer,30 columns: ["custentity_hz_credit_hold"]31 }).custentity_hz_credit_hold;3233 if (onHold) {34 so.setValue({ fieldId: "orderstatus", value: "A" });35 so.setValue({ fieldId: "memo", value: "Held — customer on credit hold" });36 log.audit("Credit hold", "Order held for customer " + customer);37 return;38 }3940 so.setValue({ fieldId: "custbody_hz_approval_tier", value: tier });41 so.setValue({ fieldId: "custbody_hz_approver", value: resolveApprover(tier) });4243 log.audit({44 title: "Approval routed",45 details: "total=" + total + " tier=" + tier46 });47 };4849 return { beforeSubmit };50});
Paused — the next statement is line 24. Click the gutter to set a breakpoint.
Watches
| Expression | Value |
|---|---|
| total | 18420 number |
| subsidiary | "2" string |
| tier | "manager" string |
| customer | "4471" string |
| onHold | false boolean |
| context.type | "create" string |
| runtime.getCurrentUser().id | 1042 number |
| runtime.getCurrentScript().getRemainingUsage() | 873 number |
Call stack
- getApprovalTierhz_so_approval_ue.js:24
- beforeSubmithz_so_approval_ue.js:41
- UserEventDispatcher.invokehz_runtime_bridge.js:88
- RecordSubmitHandler.submithz_record_engine.js:214
Breakpoints
- hz_so_approval_ue.js:12Condition: total > 10000
- hz_so_approval_ue.js:24Condition: —
- hz_so_approval_ue.js:39Condition: onHold === true
- hz_invoice_ue.js:61Condition: —