I have successfully been able to get my data from the API I need to and have been able to build some apps with that data, however, we are at a point where putting that data into our own database is best. Which is why I am working with Workflows. My issue I am having is taking that RAW JSON data and transforming it into data that can be put into a DB. In our case, either DynamoDB or Redshift.
See the snippit of the JSON data:
{
"isFetching": false,
"data": {
"hasMore": true,
"continueFrom": "AdXfDnsgQ9pIUdkdAAAAAAAASjIa",
"data": [
{
"active": true,
"id": 1955177,
"syncStatus": "Exported",
"summary": null,
"referenceNumber": "S2881",
"invoiceDate": "2022-01-05T00:00:00Z",
"dueDate": "2022-01-05T00:00:00Z",
"subTotal": "14133.60",
"salesTax": "0.00",
"salesTaxCode": null,
"total": "14133.60",
"balance": "0.00",
"customer": {
"id": 1781841,
"name": "Daniel C"
},
"customerAddress": {
"street": "1111 Westwood Dr",
"unit": null,
"city": "Houston",
"state": "TX",
"zip": "77055-4923",
"country": null
},
"location": {
"id": 1792564,
"name": "Daniel C"
},
"locationAddress": {
"street": "1111 Westwood Dr",
"unit": null,
"city": "Houston",
"state": "TX",
"zip": "77055-4923",
"country": null
},
"businessUnit": {
"id": 61569,
"name": "Concrete Repair"
},
"termName": "Due On Receipt",
"createdBy": null,
"batch": null,
"depositedOn": null,
"modifiedOn": "2022-05-31T16:13:20.8933333Z",
"adjustmentToId": null,
"job": {
"id": 1928223,
"number": "S2881",
"type": "Poly Install"
},
"projectId": null,
"royalty": {
"status": "Pending",
"date": null,
"sentOn": null,
"memo": null
},
"employeeInfo": null,
"commissionEligibilityDate": null,
"items": [
{
"id": 1968654,
"description": "",
"quantity": "1.0000000000000000000",
"cost": "0.0000000000",
"totalCost": "0.00",
"inventoryLocation": null,
"price": "14133.60",
"type": "Service",
"skuName": "Cancel",
"skuId": 199585,
"total": "14133.60",
"inventory": false,
"taxable": false,
"generalLedgerAccount": null,
"costOfSaleAccount": null,
"assetAccount": null,
"membershipTypeId": 0,
"itemGroup": null,
"displayName": "Cancel",
"soldHours": null,
"modifiedOn": "2022-05-31T16:13:26.9133333Z",
"serviceDate": null,
"order": 1,
"businessUnit": {
"id": 61569,
"name": "Concrete Repair"
}
}
],
"customFields": null
},
I have tried a number of things, most recently I have tried this:
const parseRow = (query1) => ({
subtotal: query1.subTotal,
customer: query1.customer.name,
Invoice: query1.id,
// etc.
});
return _.map(data.response.data, parseRow);
No matter what I do, I keep getting errors.