Data structure names not applying

We are working on a scenario where we pull a Sales Order from our Unleashed account in order to raise a delivery job in Detrack.

To do this successfully, we need some field names to be changed from Unleashed default names, to Detrack’s required names.

So we have created a Data Structure to get all the data we need, and modify the field names of three pieces of data: “Product Code” should be “sku”, “Product Description” as “description” and “Order Quantity” as “quantity”.

For whatever reason, we are not seeing these field names changed, so as a result, when we send the payload via Detrack API, the incorrect field names cause 0 line items to be added.

Here’s the Data Structure:

Here’s the output from a JSON Aggregator, with none of our edited field names:

What am I doing wrong? Why does the payload still have the default names?

Welcome to the Make community!

1. Screenshots of module fields

Please share screenshots of relevant module field mappings (i.e. [43]) in question? It would really help other community members to see what you’re looking at.

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:
blueprint.json (12.3 KB)

3. And most importantly, Output bundles

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of the each module, save the contents as a text file, and upload it here into this discussion thread:
Screenshot_2023-10-06_141025

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

Hi @Marketing_EGA,

I am not comfortable with JSON, but I made this very simple experimentation about key renaming:
Rename_Key_in_JSON.json (11.2 KB), and in both cases, the keys are well renamed.
Note: when you use the “Aggregate to JSON” module, it produces an array…
As @samliew said, upload your blueprint (and some anonymized data), it will be very helpfull.

PBI

2 Likes

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:
image

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):
image

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!