Forum Discussion
The easiest is to use a for loop. Depending on your use case, this may not be what you're after.
{% for mod in b.modules %}
mod.code
{% endfor %}
A use case I'm working with is fetching a report from quickbase, then iterating over the results. Each row returned has an array of locations (similar to modules). Using two different fields, I capture all the locations returned, and then grab the last one based on the loop index within the for loop. Hope this helps.
{# code for locations field #}
{% set vals = namespace(value=[]) %}
{% for val in d.n19.value %}
{% set vals.value = vals.value | append(val) %}
{% endfor %}
{{ vals.value | join("; ") }}
Which produces the values in the record as:
Bangalore - Karnataka - India; Kochi - Kerala - India; Noida - Uttar Pradesh - India |
Grabbing just the last value in the array:
{# one value in locations - example #}
{% for val in d.n19.value %}
{% if loop.last %}
{{ val }}
{% endif %}
{% endfor %}
Which produces the value in the record as:
Noida - Uttar Pradesh - India |
- Srishha5 months agoQrew Member
Thank you, Mez , for your valuable insights. However, my specific concern is navigating through the path of modules to iterate over JSON records and insert each record individually into the table rather than using for loop in Jinja. Any guidance on achieving this would be greatly appreciated.