Default values for percentage input not visible in iteration

Hi,

When using the following code, the default percentage appears in the output:

{% assign total = 500 %}
{% assign part = 25 %}
{% assign pct = part/total %}
Total {{ total }}
Total {{ part }}
Pct {{ pct }}
Pct formatted {{ pct|percentage }}
{% input custom.ic.ic_test_pct as:percentage default:pct %}
Input pct: {{ custom.ic.ic_test_pct }}

However, when doing basically the same thing in an iteration, it will not appear:

{% for person in period.people %}
{% $0+ person.amount_of_shares %}
{% endfor %}
{% assign total_amount_of_shares = $0 %}

{% for person in period.people %}

{{ person.name }}

{% assign amount_of_shares = person.amount_of_shares | plus: 0 %}
Amount of shares: {{ amount_of_shares }}

{% assign pct_of_shares = amount_of_shares/total_amount_of_shares %}
Percentage of shares : {{ pct_of_shares }}

Percentage of shares (formatted): {{ pct_of_shares | percentage }}

{% input person.custom.ic_ubo_pct_of_shares as:percentage default=pct_of_shares %}
{% input custom.ic.ic_ubo_pct_of_shares as:percentage default=pct_of_shares %}

{% endfor %}

Any help is appreciated.

With friendly regards,
Takis

Hi @Panagiotis_Issaris,

Your default attribute needs to be coded as:

{% input person.custom.ic_ubo_pct_of_shares as:percentage default:pct_of_shares %}
{% input custom.ic.ic_ubo_pct_of_shares as:percentage default:pct_of_shares %} 

so as:

default:some_var

and not with a =

Could you try again?

PS if you need to check values of shareholders, it is better to loop over period.shareholders instead of period.people :wink:

Hi Sven,

Oh! A typo… I should have seen that… it was driving me mad that it worked in the small template, and failed in the large one :stuck_out_tongue:

Thanks!!!

And thanks for the suggestion! :slight_smile:

I’ve been there as well, so :relaxed: