NetSuite allows for the creation of purchase orders based on a sales order using SuiteScript. Special Order purchase orders, which are typically used for drop-ship transactions, can be automatically generated by leveraging SuiteScript’s record.create function. Below is an example script that demonstrates the process.
var po_params = {
‘recordmode’: ‘dynamic’,
‘soid’: salesOrderIdICPO, // Sales order ID from which PO is being created
‘poentity’: poVendorICPO, // Vendor ID for the PO
‘specord’: true, // Indicates a special order
‘custid’: custIdICPO, // Customer ID
‘nexus’: nexus, // Nexus or tax details for the transaction
‘entity’: poVendorICPO, // Vendor for the PO
‘customform’: 189 // Custom form ID for the purchase order
};
// Create a Purchase Order
var po = record.create({
type: record.Type.PURCHASE_ORDER,
isDynamic: true,
defaultValues: po_params
});
Breakdown of Key Parameters:
- recordmode: Set to
'dynamic'to use the dynamic record mode, which allows for easier manipulation of the record. - soid: The ID of the sales order from which the purchase order is derived.
- poentity: The vendor entity associated with the purchase order.
- specord: A custom boolean field to denote that the PO is for a special order (e.g., drop-ship).
- custid: The customer ID for whom the purchase order is created.
- nexus: The nexus (tax jurisdiction) for the transaction, if applicable.
- entity: The vendor entity (same as
poentity). - customform: Specifies the custom form used to create the purchase order.