Question

Help with using Input: "line item group" on Zapier platform

  • 7 June 2022
  • 1 reply
  • 129 views

Hi Good day everyone!

 

While i was constructing a code to create invoices based on variables such as having 1 to 6 multiple items that may vary with the input order, i faced a blockade of not being able to create a “flexible” item coding whereby if input order has 1 item, only 1 item will show and if input order has 6 items, 6 item will show without any extra spaces or additional string/numbers in the result.

 

Could an expert please advise on how i may edit my code such that it is able to do a search on the input and find “line item group” inputs and listing them under invoice > items ? 

 

Here is my code thus far: (Only able to return item_1 at the moment. I tried item_2 and linked them with “&” but it does not work.)

const options = {
  url: 'https://api-test.com/test/v1/test',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Ocp-Apim-Subscription-Key':'{{bundle.authData.Ocp-Apim-Subscription-Key}}'
  },
  body: JSON.parse({
    meta: {
      language_code: '{{bundle.inputData.language_code}}',
      business_model: '{{bundle.inputData.business_model}}',
      tax_type: '{{bundle.inputData.tax_type}}',
      currency_code: '{{bundle.inputData.currency_code}}',
      country_code: '{{bundle.inputData.country_code}}',
      invoice_type: '{{bundle.inputData.invoice_type}}',
      invoice_number: '{{bundle.inputData.invoice_number}}',
      logo: 'https://misc-image.png',
      pdf_response: true,
      html_response: true
    },
    supplier: {
      company_name: '{{bundle.inputData.supplier_company_name}}',
      address: '{{bundle.inputData.supplier_address}}',
      country: '{{bundle.inputData.supplier_country}}',
      tin: '{{bundle.inputData.supplier_tin}}'
    },
    customer: {
      company_name: '{{bundle.inputData.customer_company_name}}',
      address: '{{bundle.inputData.customer_address}}',
      country: '{{bundle.inputData.customer_country}}',
      tin: '{{bundle.inputData.customer_tin}}'
    },
    invoice: {
      delivery_date: '{{bundle.inputData.delivery_date}}',
      payment_type: '{{bundle.inputData.payment_type}}',
      items: '{{bundle.inputData.items_1}}',
      total_net_amount: '{{bundle.inputData.total_net_amount}}',
      discount: '{{bundle.inputData.discount}}',
      total_tax_amount: '{{bundle.inputData.total_tax_amount}}',
      total_amount: '{{bundle.inputData.total_amount}}',
      note: '{{bundle.inputData.note}}'
    }
  })
};

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = response.json;

    // You can do any parsing you need for results here before returning them

    return results;
  });

   


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +9

Hey there, @Jonathan Oh! I wanted to pop in and see if you were able to get this sorted? Keep us posted on your success!