Library
Some APIs that return data allow you to extend and customise the response format. This is done by defining a object structure, and passing that template object as part of your query.
Example. A normal request for a purchase order is thus
POST /fd1/purchaseorders/get_purchaseorder_header
{
"a": "purchaseorders.get_purchaseorder_header",
"q": {
"cust_ponum": 12345
}
}
Or the GET equivalent, (GET /fd1/purchaseorders/get_purchaseorder_header?cust_ponum=12345)
This instructs Fieldpine to return the default details about purchase order 12345. Invariably this will always be too much or too little. You can therefore add a "qo" object that defines what you want to receive and how it is structured
POST /fd1/purchaseorders/get_purchaseorder_header
{
"a": "purchaseorders.get_purchaseorder_header",
"q": {
"cust_ponum": 12345
},
"qo": {
"poid": true,
"AnotherNameForId": "poid",
"entrydt": true,
"completeddt": true,
"theSupplier": {
"name": "supplier.name",
"phone": "supplier.phone"
},
"No_of_lines_on_PO": "poline._count"
}
}
You don't really need to learn this for simple use cases, just do this
Simple Example, starting from a "sale"
... qo: {
saleid: true, // Return current sales id#
total_extax: true, // Return total value of this sale, exclusive tax
customer: {
id: "sale.cid", // What is the customers id# (if any)
email: "customer.email", // Lets get their email too
totalsalecount: "customer.sales._count" // Can we also get the total number of sales this customer has ever made
}
}