What's the best way to combine data from multiple modules and output it in a Make An API Call module?

QUESTION: What’s the best way to combine data from multiple modules and output it in a Make An API Call module?

Problem

I’m trying to combine both Transaction Line Items and Stripe Fees and output them in the QuickBooks Make An API Call module. Not sure if I need to use something like the Parse JSON module to then format the Iterator Array into the QB “Line” format. Or, if I’m just making things hard for myself and there’s an easier way…

Use Case

Essentially, I want all line items + all Stripe Fees for a given transaction to be part of one Sales Receipt/Invoice. They are coming from different modules further up the Scenario, so they need to be combined some how.


I’ve seen some previous questions asking about this exact scenario, but each of the solutions isn’t detailed enough for me to understand how to implement it myself (missing solutions/partial solutions).

I’ve tried Iterators, Aggregators, JSON Parsing and I’m now stuck.

Any help would be great!

The place you’re getting a (collection) rather than text is where you need to most likely need to use a map() to extract what you need from 75.array[]

Don’t boil the ocean. Just take it element by element until you get your full string.

3 Likes

SOLUTION

Here’s the solution I came up with after HOURS of debugging and trying things out - which I hope will help someone in the future:

  1. Used Iterator to collate & handle if there are multiple Stripe Fees (Stripe + Application Fees)

  2. Set Multiple Variables module to define the Fee Variables

  3. Array Aggregator to collate the Fee Lines to use further down the line

  1. Used the Add Function in the Iterator to combine the Line Items with the Stripe Fees Array

  1. Set Multiple Variables module to define the Line Item + Fee Variables

  1. Array Aggregator to combine the data/bundles into the QB Line Item format. In here, I used a nested IF and IfEmpty function to swap out the Line Item Amounts depending on if there’s a value or not. (Needed this to handle the Fee Amount, which comes from the Balance Transaction Module and won’t have an invoice amount.

  1. Aggregate to JSON to transform the Array into the QB JSON Line Item format. (Not sure this is needed since the Array Aggregator is doing something similar, but will play with that later)

  1. In the QuickBooks Make An API Call module, I used the Substring function to trim the extra {} brackets that the Array Aggregator creates

And voila, it worked! Valid JSON request being sent to QuickBooks from Make, handling multiple Line Items + Fees.

I’m now stuck on getting QB to create a Sales Receipt with this JSON, however. It’s coming back with a TaxCode/TaxRef error:

Error ValidationFault: Invalid Tax Rate (Invalid Tax Rate : Invalid tax rate id - 10)

But I’m A LOT closer to the end solution :sweat_smile::partying_face:

2 Likes

Thanks for the suggestion, Alex.

The solution I came up with for that part was to:

  1. Replace the Create JSON module further up the scenario with the Array Aggregator module
  2. In the Make an API Call, replace the Array Aggregator map with the Create JSON module further down the scenario and do some trimming of the output using the Substring function. :grin:

1 Like