Skip to main content

I run javascript code to create line items of invoices, where each invoice can contain multiple line items.  

I can successfully use a Loop Action to loop through the invoices but the line items for each invoice seems to show every line item across all invoices.  How can I loop trough each line item with its corresponding line items so that I can create invoices in QBO.

Here is the output of the javascript code:
{
  "myLineItems": m
    {
      "CustomerName": "Test for Invoicing",
      "InvoiceDate": "2024-04-14",
      "Terms": "Net 30",
      "LineItems": Â
        {
          "Description": "105587",
          "Amount": 200,
          "DetailType": "SalesItemLineDetail",
          "SalesItemLineDetail": {
            "ItemRef": {
              "value": "1"
            },
            "Quantity": 20,
            "UnitPrice": 10,
            "TaxCodeRef": {
              "value": "NON"
            }
          }
        },
        {
          "Description": "105587",
          "Amount": 195,
          "DetailType": "SalesItemLineDetail",
          "SalesItemLineDetail": {
            "ItemRef": {
              "value": "1"
            },
            "Quantity": 19.5,
            "UnitPrice": 10,
            "TaxCodeRef": {
              "value": "NON"
            }
          }
        }
      ]
    },
    {
      "CustomerName": "Test 2 for Invoicing",
      "InvoiceDate": "2024-04-14",
      "Terms": "Net 30",
      "LineItems":  
        {
          "Description": "105593",
          "Amount": 83.7,
          "DetailType": "SalesItemLineDetail",
          "SalesItemLineDetail": {
            "ItemRef": {
              "value": "1"
            },
            "Quantity": 18.6,
            "UnitPrice": 4.5,
            "TaxCodeRef": {
              "value": "NON"
            }
          }
        }
      ]
    }
  ]
}

 

Below is what the Loop output is:

 

Â