Library
Webhooks & Firehoses
Get Purchase Orders Header
Example
POST /fd1/purchaseorders/get_purchaseorder_header
{
"a": "purchaseorders.get_purchaseorder_header",
"q": {
"cust_ponum": 12345
}
}
Or
GET /fd1/purchaseorders/get_purchaseorder_header?cust_ponum=12345
Example - Fetching with Additional Details
The following query requests a purchase order header, and additional supporting information. This is done via a "qo" parameter defining the return object structure
POST /fd1/purchaseorders/get_purchaseorder_header
{
"a": "purchaseorders.get_purchaseorder_header",
"q": {
"cust_ponum": 12345
},
"qo": {
"spid": true,
"physkey": true,
"entrydt": true,
"ship_to_location": true,
"storename": "ship_to_location.name",
"supplier": {
"name": "supplier.name",
"myob_externalid": "supplier.myob_externalid",
"gst": "supplier.gst"
},
"indispute": "purchaseorder.indispute.count",
"approvedtopay": "purchaseorder.approvedtopay",
"received_using_pocost": "purchaseorder.received.value.pocost"
}
}
Or using a GET
// Define the structure we want
let qo = {
spid: true,
physkey: true,
entrydt: true,
ship_to_location: true,
storename: "ship_to_location.name",
supplier: {
name: "supplier.name",
myob_externalid: "supplier.myob_externalid",
gst: "supplier.gst"
},
indispute: "purchaseorder.indispute.count",
approvedtopay: "purchaseorder.approvedtopay",
received_using_pocost: "purchaseorder.received.value.pocost"
}
// convert that to a URI query string.
const urifmt = encodeURIComponent(JSON.stringify(qo));
// Do the query
// The "urifmt" is technically a constant string, so you can simply enter the value, but creating an object first
// can make development clearer. Your decision.
fetch("/fd1/purchaseorders/get_purchaseorder_header?cust_ponum=12345&_qo="+urifmt).then(....)
When run, the response should look as follows. Note that "rows" is always an array, even for known single value responses.
{
data: {
rows: [
{
spid: 12345,
physkey: "KLKIRIU383BN9284HGNNB3DDE",
entrydt: "2023-08-06 14:53:26",
ship_to_location: 4,
storename: "Seatoun Main Street",
supplier: {
name: "Acme Widgets",
myob_externalid: "U9DG28374GFHF86",
gst: "123-456-789"
},
indispute: 1,
approvedtopay: 516.85,
received_using_pocost: 827.14
}
]
}
}