Hello, dear Glide Makers!
I’m facing an issue while trying to insert my JSON data into PDF Monkey to generate an invoice document.
Context:
I have built a template that generates an invoice based on the products a user selects in their cart. Each product is stored in one or multiple warehouses, each with different delivery times. The invoice needs to reflect this by displaying the products in separate tables based on their respective storage locations and delivery times.
To achieve this, I created an IF condition in my template to check each product’s storage and dynamically display it in the relevant table along with its quantity, price, and expected delivery time.
My HTML code piece with a table
<!-- Table of products for Storage 1 -->
{% assign storage1_items = false %}
{% for item in items %}
{% if item.storage1 != "" %}
{% assign storage1_items = true %}
{% endif %}
{% endfor %}
{% if storage1_items %}
<h2>Products (Delivery time: {{ items[0].storage1_time }})</h2>
<table class="product-table">
<tr>
<th>No.</th>
<th>Products (works, services)</th>
<th>Quantity</th>
<th>Unit</th>
<th>Price</th>
<th>Total</th>
</tr>
{% for item in items %}
{% if item.storage1 != "" %}
<tr>
<td>{{ forloop.index }}</td>
<td>{{ item.description }}</td>
<td>{{ item.storage1 }}</td>
<td>pcs</td>
<td>{{ item.price }}</td>
<td>{{ item.price | times: item.storage1 }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
{% endif %}
<!-- Table of products for Storage 2 -->
{% assign storage2_items = false %}
{% for item in items %}
{% if item.storage2 != "" %}
{% assign storage2_items = true %}
{% endif %}
{% endfor %}
{% if storage2_items %}
<h2>Products (Delivery time: {{ items[0].storage2_time }})</h2>
<table class="product-table">
<tr>
<th>No.</th>
<th>Products (works, services)</th>
<th>Quantity</th>
<th>Unit</th>
<th>Price</th>
<th>Total</th>
</tr>
{% for item in items %}
{% if item.storage2 != "" %}
<tr>
<td>{{ forloop.index }}</td>
<td>{{ item.description }}</td>
<td>{{ item.storage2 }}</td>
<td>pcs</td>
<td>{{ item.price }}</td>
<td>{{ item.price | times: item.storage2 }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
{% endif %}
<!-- Table of products for Storage 3 -->
{% assign storage3_items = false %}
{% for item in items %}
{% if item.storage3 != "" %}
{% assign storage3_items = true %}
{% endif %}
{% endfor %}
{% if storage3_items %}
<h2>Products (Delivery time: {{ items[0].storage3_time }})</h2>
<table class="product-table">
<tr>
<th>No.</th>
<th>Products (works, services)</th>
<th>Quantity</th>
<th>Unit</th>
<th>Price</th>
<th>Total</th>
</tr>
{% for item in items %}
{% if item.storage3 != "" %}
<tr>
<td>{{ forloop.index }}</td>
<td>{{ item.description }}</td>
<td>{{ item.storage3 }}</td>
<td>pcs</td>
<td>{{ item.price }}</td>
<td>{{ item.price | times: item.storage3 }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
{% endif %}
My Data structure
{
"invoice_number": "1",
"date": "01/02/2025",
"eur_rate": "102.1301",
"buyer": {
"user_id": "qE66fsG0SvufjorYzTEO9w",
"company_name": "",
"inn": "",
"kpp": "",
"address": ""
},
"items": [
{
"product_id": "2CDG110211R0011",
"description": "Fan coil controller, 2 x PWM, manual control, 3 stages, MDRC",
"total_quantity": "300",
"price": "24483.6",
"storage1": "10",
"storage2": "4",
"storage3": "286",
"storage1_time": "3-4 days",
"storage2_time": "2-3 weeks",
"storage3_time": "8-10 weeks"
},
{
"product_id": "2CKA006132A0342",
"description": "KNX Presence Mini White",
"total_quantity": "20",
"price": "13267.7",
"storage1": "20",
"storage2": "",
"storage3": "",
"storage1_time": "3-4 days",
"storage2_time": "",
"storage3_time": ""
}
]
}
Problem:
When I try to send this JSON data to PDF Monkey via an Action in Glide, it refuses to generate the document.
- I’m taking the final JSON output and sending it to PDF Monkey, but it fails every time.
- No matter how I modify my data structure, the request does not go through, and I receive an error message.
Has anyone faced a similar issue when sending JSON data to PDF Monkey?
What could be causing this error? Any suggestions on how to properly structure the JSON request or debug the issue?
Thanks in advance!