Thanks samliew, I’ve gathered some more info to assist with debugging.
Here is the current v1 scenario:
unleasehd-to-detrack_v1.json (16.8 KB)
Quick explainer:
- First module pings our Unleashed database every 15 min and fetches a Sales Order which includes delivery info like order number, name and address, along with line items comprising a complete order.
- Second module creates the JSON data. I’ve setup a data structure of the minimum required fields that Detrack wants.
- Third module sends a JSON payload to Detrack to create a Delivery Job. This is working with the delivery info, but does not include the line items.
Data structure for Sales Orders from Unleashed:
- There are 3 line items in this order (2 products, 1 freight charge), along with the customer’s name, address and order number. For each line item, we only need each SKU, Description and Quantity.
Field mapping in the Create JSON module:
- I get only the first Line Item with this configuration. If I use the Map option and map the SalesOrderLines to the items collection, I get all the line items as well as all of their data (not just the SKU/Code, Description and Quantity).
If I map the fields with the SO data like this, I only get a single line item in the Delivery Job:
Here’s the output data from this setup - you can see just 1 line item, but the field names are correct (sku, description, quantity):
If I use that JSON output as the API payload, it successfully creates the Delivery Job in Detrack but with only 1 line item.
If I map the fields with the SalesOrderLines data, I get all line items but it incudes all sorts of other fields that I have removed from my Data Structure (not sure why that’s happening either):
Here’s the output data from this setup - you can see all the line items, but the field names are incorrect (ProductCode, ProductDescription, OrderQuantity) - I was expecting my Data Structure names to replace those field names:
To create a Delivery Order in Detrack, this is what the minimum required JSON payload needs to look like - any deviations from this and it doesn’t accept the line items.
{
“data”: {
“type”: “Delivery”,
“do_number”: “OrderNumber”,
“date”: “RequiredDate”,
“start_date”: “OrderDate”,
“order_number”: “OrderNumber”,
“address”: “DeliveryStreetAddress DeliverySuburb DeliveryRegion DeliveryPostCode DeliveryCountry”,
“phone_number”: “DeliveryContact.MobilePhone”,
“notify_email”: “username@domain.com”,
“items”: [{
“sku”: “ProductCode1”,
“description”: “ProductDescription1”,
“quantity”: 1
},{
“sku”: “ProductCode2”,
“description”: “ProductDescription2”,
“quantity”: 2
},{
“sku”: “ProductCode3”,
“description”: “ProductDescription3”,
“quantity”: 3
},{
“sku”: “ProductCode1”,
“description”: “ProductDescription4”,
“quantity”: 4
}]
}
}
More info in the API docs here:
Surely I don’t need to start parsing data and performing regex replacements and string gymnastics to re-create a clean payload? At this point I’m in over my head because I don’t know what I don’t know and my experience with Make is limited.
Any assistance you can offer is greatly appreciated!