Create iteration on a JSON Body

Describe the problem/error/question

Hi the goal here is to create invoices with different products from a google sheet.
For each product, we will have 5 columns on the sheet. (label, price, quantity, unit, VAT)
Which means that if I have 5 products I’ll have 25 columns.
I can’t know how many products will be on an invoice.

What is the error message (if any)?

I don’t have an error message but I’m not able to create an invoice with more than one product… I did the mapping only for the 5 columns of the first product but I don’t know how to automate the next products.

Please share your workflow

Here’s what a product looks like on the request

"line_items":[
         {
            "product":{
               "label": "MacBook",
               "unit": "piece",
               "price": 1300,
               "vat_rate": "FR_200",
               "currency": "EUR"
            },
            "label": "MacBook",
            "quantity": 1
         }
      ]

I would like that for each product that I have on an order from the Google Sheet, those lines are iterate automatically. Which means that if I have 2 products it will look like this :

"line_items":[
         {
            "product":{
               "label": "MacBook",
               "unit": "piece",
               "price": 1300,
               "vat_rate": "FR_200",
               "currency": "EUR"
            },
            "label": "MacBook",
            "quantity": 1
         },
         {.  
            "product":{
               "label": "MacBook2",
               "unit": "piece",
               "price": 1400,
               "vat_rate": "FR_200",
               "currency": "EUR"
            },
            "label": "MacBook",
            "quantity": 1
         }
      ]

Share the output returned by the last node

Here we’ve got 3 invoices created, but every time there is only one product :

[
  {
    "invoice": {
      "amount": "1300.0",
      "currency_amount_before_tax": "1083.33",
      "currency_amount": "1300.0",
      "currency_tax": "216.67",
      "currency": "EUR",
      "date": "2023-01-11",
      "deadline": "2023-01-11",
      "discount_type": "relative",
      "discount": "0.0",
      "filename": null,
      "invoice_number": "",
      "language": "fr_FR",
      "paid": false,
      "pdf_invoice_free_text": "",
      "pdf_invoice_subject": "",
      "quote_group_uuid": "21794896-4ef7-4ce7-b7b3-1c9829adf565",
      "remaining_amount": "1300.0",
      "special_mention": null,
      "status": "draft",
      "updated_at": "2023-06-09T19:59:56.033532Z",
      "id": "V2BKKL6SNT",
      "label": "Facture Alexandre  Baladi (label généré)",
      "is_draft": true,
      "exchange_rate": 1,
      "file_url": "https://app.pennylane.com/public/invoice/pdf?encrypted_id=n01oS%2Fi%2FdHlN0YVT5CIxWLYaipkx%2FcRovg%2B48bFMMJpQWEklaiosTwb2g%2B1i54%2FqziqjHuguCEPNbLxqLEMjxA%3D%3D--7mBC%2BkSpsIGnDs1S--gY9PMUUzsUBlE1tJueazZA%3D%3D",
      "source": "external_api_create",
      "customer": {
        "source_id": "9d741283-03ef-4b0e-9c20-a539e80c796e",
        "customer_type": "individual",
        "name": "Alexandre  Baladi",
        "billing_iban": null,
        "payment_conditions": "30_days",
        "recipient": "",
        "updated_at": "2023-06-09T19:36:52.218215Z",
        "phone": "",
        "reference": "",
        "first_name": "Alexandre ",
        "last_name": "Baladi",
        "gender": null,
        "emails": [
          "[email protected]"
        ],
        "billing_address": {
          "address": "6 rue du lièvre ",
          "postal_code": "86500",
          "city": "Reims",
          "country_alpha2": "FR"
        },
        "delivery_address": {
          "address": "",
          "postal_code": "",
          "city": "",
          "country_alpha2": ""
        }
      },
      "payments": [],
      "line_items": [
        {
          "id": 51208962,
          "label": "MacBook",
          "unit": "piece",
          "quantity": "1.0",
          "amount": "1300.0",
          "currency_amount": "1300.0",
          "description": "",
          "vat_rate": "FR_200",
          "currency_price_before_tax": "1083.33",
          "currency_tax": "216.67",
          "raw_currency_unit_price": "1083.333333",
          "product_id": "072510bc-544a-49a7-b720-7438a3c065b8"
        }
      ],
      "matched_transactions": [],
      "transactions_reference": null,
      "categories": []
    }
  },
  {
    "invoice": {
      "amount": "1300.0",
      "currency_amount_before_tax": "1083.33",
      "currency_amount": "1300.0",
      "currency_tax": "216.67",
      "currency": "EUR",
      "date": "2023-09-01",
      "deadline": "2023-09-01",
      "discount_type": "relative",
      "discount": "0.0",
      "filename": null,
      "invoice_number": "",
      "language": "fr_FR",
      "paid": false,
      "pdf_invoice_free_text": "",
      "pdf_invoice_subject": "",
      "quote_group_uuid": "6d83c17b-2bcd-4322-bb11-54343ecd450c",
      "remaining_amount": "1300.0",
      "special_mention": null,
      "status": "draft",
      "updated_at": "2023-06-09T19:59:56.235033Z",
      "id": "BCPCJPUD1K",
      "label": "Facture Alexandre  Baladi (label généré)",
      "is_draft": true,
      "exchange_rate": 1,
      "file_url": "https://app.pennylane.com/public/invoice/pdf?encrypted_id=cgdRvHbL9UmDH6wSJQRv%2FcusvTgga43lNx7a6WzJNswuSQ2SAHpwLwWvzwVgG1joLWrayzwzC%2FsiohN2lJC9SQ%3D%3D--ICTUK7V5TukXyEi1--PohmnPTQ3LyhvQtWnr68UA%3D%3D",
      "source": "external_api_create",
      "customer": {
        "source_id": "9d741283-03ef-4b0e-9c20-a539e80c796e",
        "customer_type": "individual",
        "name": "Alexandre  Baladi",
        "billing_iban": null,
        "payment_conditions": "30_days",
        "recipient": "",
        "updated_at": "2023-06-09T19:36:52.218215Z",
        "phone": "",
        "reference": "",
        "first_name": "Alexandre ",
        "last_name": "Baladi",
        "gender": null,
        "emails": [
          "[email protected]"
        ],
        "billing_address": {
          "address": "6 rue du lièvre ",
          "postal_code": "86500",
          "city": "Reims",
          "country_alpha2": "FR"
        },
        "delivery_address": {
          "address": "",
          "postal_code": "",
          "city": "",
          "country_alpha2": ""
        }
      },
      "payments": [],
      "line_items": [
        {
          "id": 51208963,
          "label": "MacBook",
          "unit": "piece",
          "quantity": "1.0",
          "amount": "1300.0",
          "currency_amount": "1300.0",
          "description": "",
          "vat_rate": "FR_200",
          "currency_price_before_tax": "1083.33",
          "currency_tax": "216.67",
          "raw_currency_unit_price": "1083.333333",
          "product_id": "18fac608-d458-4ae1-98a1-4e5792c8525b"
        }
      ],
      "matched_transactions": [],
      "transactions_reference": null,
      "categories": []
    }
  },
  {
    "invoice": {
      "amount": "1300.0",
      "currency_amount_before_tax": "1083.33",
      "currency_amount": "1300.0",
      "currency_tax": "216.67",
      "currency": "EUR",
      "date": "2023-11-14",
      "deadline": "2023-11-14",
      "discount_type": "relative",
      "discount": "0.0",
      "filename": null,
      "invoice_number": "",
      "language": "fr_FR",
      "paid": false,
      "pdf_invoice_free_text": "",
      "pdf_invoice_subject": "",
      "quote_group_uuid": "6e29f0d4-16e3-4cc4-b1ff-a7a9b7e9d7e4",
      "remaining_amount": "1300.0",
      "special_mention": null,
      "status": "draft",
      "updated_at": "2023-06-09T19:59:56.448888Z",
      "id": "AUBPEMNZXE",
      "label": "Facture Zapier Zapier (label généré)",
      "is_draft": true,
      "exchange_rate": 1,
      "file_url": "https://app.pennylane.com/public/invoice/pdf?encrypted_id=so3PAPLfBzqSbxorvU1SAfk%2Brq%2BOVF3DvGSGNVJBccpPC%2B5BFbPa05D8cdnvTShnygU2Nc6I%2BtomcM%2B0C8xLNA%3D%3D--Z1eAbABZL8yTKz18--b3fRKYWSoYwc4BHket5wpg%3D%3D",
      "source": "external_api_create",
      "customer": {
        "source_id": "a4df57a8-2d83-4afa-a164-9b15a92892f4",
        "customer_type": "individual",
        "name": "Zapier Zapier",
        "billing_iban": null,
        "payment_conditions": "30_days",
        "recipient": "",
        "updated_at": "2023-06-09T19:36:52.660969Z",
        "phone": "",
        "reference": "",
        "first_name": "Zapier",
        "last_name": "Zapier",
        "gender": null,
        "emails": [
          "[email protected]"
        ],
        "billing_address": {
          "address": "6 rue du lièvre ",
          "postal_code": "86500",
          "city": "Reims",
          "country_alpha2": "FR"
        },
        "delivery_address": {
          "address": "",
          "postal_code": "",
          "city": "",
          "country_alpha2": ""
        }
      },
      "payments": [],
      "line_items": [
        {
          "id": 51208964,
          "label": "MacBook",
          "unit": "piece",
          "quantity": "1.0",
          "amount": "1300.0",
          "currency_amount": "1300.0",
          "description": "",
          "vat_rate": "FR_200",
          "currency_price_before_tax": "1083.33",
          "currency_tax": "216.67",
          "raw_currency_unit_price": "1083.333333",
          "product_id": "c890f812-090a-4245-abd4-5f326d67834b"
        }
      ],
      "matched_transactions": [],
      "transactions_reference": null,
      "categories": []
    }
  }
]

Thanks a lot for your help !

Can you please double-check/confirm using PostMan or cURL that you get ALL the line items from

        "method": "POST"
        "url": "https://app.pennylane.com/api/external/v1/customer_invoices"
        "jsonBody": "={\n   \"invoice\":{\n    \"customer\":...}"

Hi @getk, yes I can confirm.

You can find the documention here to create an invoice. The part that is relevant here is line_items > LINE ITEM WITH NEW PRODUCT which allows to add products on the invoice.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.