Adding a capture to an input field

Hi there!

I’ve seen another post on here about the same subject, but it didn’t really address the issue that I’m having.

I am trying to create input fields using dynamic variables, but when I type something into the input box, the value disappears.

Below is a snippet of my code:

{% stripnewlines %}
  {% assign asset_selection = "local" %}
  {% assign asset = "fixed_assets" %}
  
  {% capture proceeds %}
    {{ asset_selection }}_proceeds.{{ asset }}
  {% endcapture %}
  
  {% capture base_cost %}
    {{ asset_selection }}_base_cost.{{ asset }}
  {% endcapture %}
  
  {% capture number_of_transactions %}
    {{ asset_selection }}_number_of_transactions.{{ asset }}
  {% endcapture %}
  
  {% capture asset_gain %}
    {{ asset_selection }}_{{ asset }}_gain
  {% endcapture %}
  
  {% capture total_gain %}
    total_{{ asset_selection }}_gain
  {% endcapture %}
  
  {% capture asset_loss %}
    {{ asset_selection }}_{{ asset }}_loss
  {% endcapture %}
  
  {% capture total_loss %}
    total_{{ asset_selection }}_loss
  {% endcapture %}
  
  {% comment %}Table Content{% endcomment %}
  
  <table>
    {% ifi INT(custom.[proceeds]) != 0 or INT(custom.[base_cost]) != 0 %}
      <tr>
        <td class="usr-align-center">
          {% ic %}
            {::infotext as="hover"}
              e.g. Land, buildings, mineral rights
            {:/infotext}
          {% endic %}
        </td>
        <td>
          Fixed/immoveable assets
        </td>
        <td>
          &nbsp;
        </td>
        <td class="usr-align-right">
          {% input custom.[proceeds] as:currency precision:0 required:true placeholder:0 %}
        </td>
        <td>
          &nbsp;
        </td>
        <td class="usr-align-right">
          {% input custom.[base_cost] as:currency precision:0 required:true placeholder:0 %}
        </td>
        <td>
          &nbsp;
        </td>
        <td class="usr-align-right">
          {% if custom.[proceeds]-custom.[base_cost] > 0 %}
            {% assign [asset_gain] = custom.[proceeds]-custom.[base_cost] %}
            {% assign [total_gain] = [total_gain]+[asset_gain] %}
            {{ [asset_gain] | currency:0 }}
          {% else %}
            {{ INT(0) }}
          {% endif %}
        </td>
        <td>
          &nbsp;
        </td>
        <td class="usr-align-right">
          {% if custom.[proceeds]-custom.[base_cost] < 0 %}
            {% assign [asset_loss] = custom.[proceeds]-custom.[base_cost] %}
            {% assign [total_loss] = [total_loss]+[asset_loss] %}
            {{ [asset_loss] | currency:0, invert:true }}
          {% else %}
            {{ INT(0) }}
          {% endif %}
        </td>
        <td>
          &nbsp;
        </td>
        <td class="usr-align-right">
          {% input custom.[number_of_transactions] as:currency precision:0 required:true placeholder:0 %}
        </td>
      </tr>
    {% endifi %}
  </table>
{% endstripnewlines %}

This is the output after a value has been entered:

Hi @NicoleP,

I’ve tried out your code but don’t have an issue with it (I can fill in all values).

Is there a specific reason why you use dynamic variables in a custom input? Perhaps to align on naming and such across all inputs?

Anyway, looking at the code I cannot see something wrong. Could you re-test above snippet you posted perhaps?

Hi @sven

Thanks for your quick response.

I have tested it out again, but am still having the same issue. Typing a value in the field is fine, but as soon as I press Enter to “save” the value, it disappears.

The reason for using dynamic variables in my case is to minimise duplication. I have to create two identical tables in my template (one for local assets and one for foreign assets) and I was advised that dynamic variables might be the way to go.

Np :relaxed:

Could you perhaps share the link to your template in a company file by mail to support@silverfin.com ?
Because I still cannot simulate it.

I’ll be sure to post here the follow-up for everyone interested of course

@NicoleP, no need to sent a mail with the link.

What you could do to search for the issue, is use the inspect functionality of your browser for that specific input variable.
for example, with Chrome, I can right-click the input and pick Inspect element to see something like this:

As one can see, the actual database variable name here is " _proceeds. " which is not a good variable name (with the spaces and all).
What happened here, is that one or 2 dynamic variables aren’t created for the input, resulting in an incorrect naming of the input.

Probably to be considered as a downside of using dynamic vars to create database variables, but with the inspect functionality you can easily find an issue
(in most cases, if the input becomes empty again after ENTER, it’s most likely an incorrect variable name, with our verify functionality in the editor sometime can detect, but not in your case due to the use of dynamic variables).