Table creating new lines on the same line

Hi,

I’ve been doing my best to correct the coding for a table I’m working on, but I must have a slight error with the coding for the total line as I’m struggling to find a workaround.

Currently when I enter data into the template, rather than providing a new line below the first, it creates a new set of columns to the right of the data, so the table is expanding horizontally rather than vertically.

Here is the code:

|Item
|Description
|Value
|Attachment
{% newline %}
|----30%-----
|----30%-----
|----20%-----:
|:----20%-----:#
{% newline %}
{% fori item in custom.petty_cash_details %}
|{% input item.title as:text placeholder:'Title' %}
|{%=$1+input item.text as:text placeholder:'Extra info' %}
|{%=$2+input item.value as:currency placeholder:0 %}
|{%=$3+input item.doc as:file_collection %}
{% assign total_amount = total_amount+item.value %}
{% endfori %}
{% comment %}<-Table_total->{% endcomment %}
{% newline %}
|
|
|{% if current_account.asset_or_expense %}
{% unless decimal_recon == true %}
{% assign difference = INT($1+account.value+total_amount) %}
{% else %}
{% assign difference = $1+account.value+total_amount %}
{% endunless %}
{% else %}
{% unless decimal_recon == true %}
{% assign difference = INT($1+account.value-total_amount) %}
{% else %}
{% assign difference = ($1+account.value-total_amount) %}
{% endunless %}{% endif %}
{% capture recon_text %}
  Account value: {{ $1+account.value | currency:0 }} <br>
  Template value: {{ total_amount | currency:0 }} <br>
  Difference: {{ difference | currency:0 }}
{% endcapture %}
{% unreconciled difference as:indicator unreconciled_text:recon_text %} **{{ total_amount | currency }}**
|
{% endstripnewlines %} 

Here is the template without any data:

Here is the template after entering a value:

Apologies if this is a simple fix, but I would be grateful for some guidance!

Many thanks,

Mike

Hi @Mike.davis,

You are indeed pretty close to the solution already:

Now, you are creating a newline right after the fori-loop.
As a result, a new iteration within that loop will not get a new line (hence the horizontal expansion)

To solve this, you could simply put the newline within the fori-loop, like this:

{% fori item in custom.petty_cash_details %}
|{% input item.title as:text placeholder:'Title' %}
|{%=$1+input item.text as:text placeholder:'Extra info' %}
|{%=$2+input item.value as:currency placeholder:0 %}
|{%=$3+input item.doc as:file_collection %}
{% assign total_amount = total_amount+item.value %}

{% newline %}

{% endfori %}
{% comment %}<-Table_total->{% endcomment %}

The table will then work as you want it to:

I hope this helps!

Kinds regards,

Michiel

Hi Michiel,

Perfect, that worked a treat - knew it would be something simple! Thank you for providing the answer so quickly :grinning:

Many thanks,

Mike