The quick answer
Inspect the raw table cells and extracted fields before treating an invoice as a bill proposal. Reconcile the retained amounts to the document, then check what the proposed transaction represents. A completed extraction job does not approve a payable. In this example, a subtotal-only proposal omits tax and the custom script returns MANUAL_REVIEW.
This walkthrough reviews a prepared SuiteScript 2.1 extraction script, runs its isolated Map/Reduce deployment and reads its output. The script has no accounting record-creation or bill-save path. It demonstrates a review control for one document layout.
Before you start
Use a dedicated File Cabinet folder containing only the fictional sample invoice. The prepared Invoice Table Review deployment reads that folder through its Input Folder ID parameter. Use your own folder's internal ID; 6204 belongs to this example.
The executing role needs access to the input file, script deployment and document-extraction service. Confirm those capabilities in the target account before running a batch. The example uses Debug logging for controlled fictional data. Restrict invoice content in production logs and diagnostic files.
The script calls N/documentCapture.documentToStructure with document type INVOICE and text, table and key-value extraction. The synchronous operation has a documented five-page limit and costs 100 governance units. Longer documents use asynchronous extraction through N/task; choosing a promise does not remove the page limit.
01. Inspect the invoice and code
The sample invoice REF-7348 states currency CAD and purchase-order reference PO-P3086. Its four line amounts are 281.25, 312.50, 500.00 and 93.75, totaling 1,187.50. It explicitly states tax 95.00, shipping 0.00, discount 0.00 and total 1,282.50.
Review the prepared code before execution. It imports file, extraction, query, runtime and logging modules. It does not import an accounting record module or save a vendor bill. It compares extracted line and summary amounts; this walkthrough does not validate each quantity multiplied by its rate.
02. Run the isolated review deployment
Confirm that the dedicated folder contains the sample PDF. Open the prepared deployment and its Parameters subtab. Check Input Folder ID, Deployed, Not Scheduled and the controlled test's Debug log level.
Choose Edit, confirm the parameter and use the save menu's Save and Execute action. Refresh the Map/Reduce status page until this instance is Complete. Pending and Processing are execution states. Complete means the code finished; read the output before deciding whether the document is usable.
03. Compare raw extraction with parsed candidates
Open the deployment's Execution Log. Inspect the raw diagnostics and parsed candidates. The walkthrough shows readable formatted copies in an external text editor; it does not add a JSON-validation page to NetSuite.
This response has empty headerRows. Its first body row contains Item, Description, Quantity, Rate CAD and Amount CAD. The parser accepts that row only when its required labels map unambiguously to distinct columns. It stops on missing or duplicate headers and malformed rows rather than shifting arbitrary data into columns.
Compare all four parsed lines with the raw cells. In this script, the extracted purchase-order reference is logged as a document value; the script does not perform a NetSuite PO match. The parser separately reads PurchaseOrder, SubTotal, TotalTax, ShippingCost and InvoiceTotal key-value fields. For this layout, discount comes from one exact Discount CAD text line followed immediately by its numeric value.
Keep missing values distinct from explicit zero. This sample retains both shipping and discount as 0.00; the script does not silently fill absent values with zero. The header audit records firstBodyRowFallback and column indexes for item, quantity, rate and amount.
04. Read the manual-review decision
The guard uses CAD minor units: line subtotal and extracted subtotal are 118750, tax is 9500, and expected and document totals are 128250. The script's proposed transaction amount is only 118750; no vendor bill is created. The guard's extracted subtotal, tax and document total reconcile, but the proposed accounting representation omits tax.
The custom validation-only guard returns MANUAL_REVIEW because the proposed transaction amount omits the extracted tax. This is not a native NetSuite tax validation or tax-code determination. Adding the tax number to JSON would not establish the correct tax code, nexus, calculation or posting treatment.
Filter the execution log to Audit. It retains Manual review required and Review complete with noTransactionCreation: true. Here, Review complete means the custom routine finished; the invoice has not passed accounting or tax validation.
The transactionCreated: false and noTransactionCreation: true values are this script's controls. The reviewed code has no accounting creation path. Those flags do not prove that no other process created a transaction elsewhere in the account.
Before adding posting, verify vendor and PO uniqueness, eligible PO lines, item or expense mappings, currency and subsidiary compatibility, tax treatment, duplicate invoice references, approvals and restart-safe processing. Matching totals alone cannot pass those checks.
Common questions
Does document extraction create a vendor bill?
documentToStructure returns extracted document information. This review script parses that information and logs a decision. It contains no bill-creation path. Any later transaction creation needs its own mappings, validation and approval controls.
Why is the Map/Reduce job Complete when the invoice needs review?
The script intentionally returns a manual-review result without throwing a job error. Complete describes execution status. Read the logged decision and its reason separately.
Can I always treat the first body row as the header?
No. In this prepared parser, the fallback applies only when that row has the complete known header signature with unique column mappings. This parser stops on missing, repeated or ambiguous labels. Test each supported document layout rather than assuming row positions.
Does a high confidence score validate accounting mappings?
No. Confidence describes recognition. It does not establish the correct vendor, purchase order, item, account, subsidiary, currency or tax treatment.
Does the promise version remove the five-page limit?
No. Use the documented asynchronous extraction path through N/task for longer documents. A promise does not turn the synchronous method into an unlimited-page operation.