ANS-1695 · SUITESCRIPT DEVELOPMENT

How to Programmatically Link a Vendor Bill to a Purchase Order in NetSuite?

Programmatically linking a Vendor Bill to a Purchase Order in NetSuite requires adherence to specific timing and line-matching conditions.

Short answer

Yes, a Vendor Bill can be programmatically linked to a Purchase Order in NetSuite. This is only possible during record creation, in a beforeSubmit script. It requires exact matching of item or expense lines and setting the orderdoc and orderline fields on the Vendor Bill's sublists with the Purchase Order's internal ID and corresponding line ID.

Scenario

NetSuite users may need to programmatically link a Vendor Bill to its corresponding Purchase Order. This is often required when automating the bill creation process to ensure accurate financial tracking and reconciliation. Establishing this linkage requires adherence to specific conditions and the correct population of certain fields.

Solution

It is possible to programmatically link a Vendor Bill to a Purchase Order in NetSuite, provided certain conditions are met.

  1. The linkage can only be established during the Vendor Bill's creation, specifically in a beforeSubmit script. Once the record is created in the database, this cannot be set, not even for new lines.

  2. The lines of the Purchase Order must be matched with the lines of the Vendor Bill. If the lines do not match (wrong item), an error will be thrown.The fields to set on the Vendor Bill's sublists are:On the "item" or "expense" sublists, the line item field is called "orderdoc" and expects the internalId of the PO.On the "item" or "expense" sublists, the line item field is called "orderline" and expects the value of the "lineid" field of the corresponding PO line. It is the Line ID, NOT the Line Sequence Number.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant