# Shareholer automatic completion

**URL:** <https://community.silverfin.com/t/shareholer-automatic-completion/2254>\
**Category:** Templates\
**Tags:** drops, list, for\_loop\
**Created:** [March 7, 2022, 8:13am UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254 "2022-03-07T08:13:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lieels01](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lieels01](https://community.silverfin.com/u/lieels01)\
**Post date:** [March 7, 2022, 8:13am UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254/1 "2022-03-07T08:13:52Z")

</div>

Hi!

I’d like to have an automatic system where the possible shareholders appear (some kind of boolean maybe) and depending on the name that is selected, the name and number of shares of the selected person should be completed automatically (if multiple shareholders selected, the text should be unavailable). I already spent hours and hours on this, but can’t seem to figure it out. Do you have any advice?

{% comment %}Aandeelhouders{% endcomment %}  
{% ic %}  
{::infotext}  
Kies de betreffende aandeelhouder:  
{% for shareholder in period.shareholders %}  
{% capture name\_id %}{{ shareholder.name | replace: ‘.’,’’ | replace: ’ ‘,’’ | remove:’-’}}{% endcapture %}  
{% ic %}{% input period.custom.[name\_id].shareholder as:boolean default:true %}{% endic %}{% assign name\_shareholder = period.custom.[name\_id].shareholder | default:true %}{% if name\_shareholder %}{% nic %}_{% endnic %} {{ shareholder.name }}{% else %}{% assign not\_all\_present = true %}{% ic %}_{{ name }}\*{% endic %}{% capture not\_present\_var %}no shareholders in Silverfin{{ forloop.index }}{% endcapture %}{% capture [not\_present\_var] %}{{ name }}{% endcapture %}{% endif %}  
{% endfor %}  
{:/infotext}  
{% endic %}

Ondergetekende {{ shareholder.name }}, houder van {{ shareholder.amount\_of\_shares }} aandelen van de {{ full\_company\_form | strip }} "{{ company.name | strip }}”, met zetel te {{ company.street | strip }}, {{ company.city | strip }}, {{ company.country | strip }}, ingeschreven in het {{ rpr\_naam }} onder nummer {{company.vat\_identifier | strip}},

---

<div class="post-metadata">

**Author:** ![Jelena\_Sutova](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/jelena_sutova/32/599_2.png) [@Jelena\_Sutova](https://community.silverfin.com/u/Jelena_Sutova)\
**Post date:** [March 7, 2022, 2:49pm UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254/2 "2022-03-07T14:49:01Z")

</div>

@lieels01

Please find below the code, which displays the list of all shareholders with options to select (enable).

For selected shareholders the following information will be displayed:

- Full name
- Number of shares
- Nature of shares
- Class of shares (if applicable)
- Number of votes (if applicable)

Please take a look and let me know if you need help to adjust the code for your cases.

Kind regards,  
Jelena

```auto
{% stripnewlines %}
{% for shareholder in period.shareholders %}
  {% if shareholder.persisted %}

    {% comment %}Assigning the type of the shareholder - "legal" or "nature"{% endcomment %}
    {% assign default_type = "" %}
    {% if shareholder.custom.represented_by_name != blank %}
      {% assign default_type = "legal" %}
    {% else %}
      {% assign default_type = "nature" %}
    {% endif %}
    {% assign type = shareholder.custom.type | default:default_type %}
    
    {% if type == "nature" %}
      {% assign words = shareholder.name | split: ' ' %}
      {% assign lastname = "" %}
      {% assign shareholder_first_name = "" %}
      {% for word in words %}
        {% if forloop.last %} {% comment %}correct for syncs like adminis{% endcomment %}
          {% assign shareholder_first_name = word %}
        {% else %}
          {% assign lastname = lastname | append:" " | append:word %}
        {% endif %}
      {% endfor %}
      {% capture shareholder_last_name %}{{ lastname | strip }}{% endcapture %}
      {% assign first_name = shareholder.custom.first_name | default:shareholder_first_name %}
      {% assign last_name = shareholder.custom.last_name | default:shareholder_last_name %}
      {% capture full_name %}{{ first_name }} {{ last_name }}{% endcapture %}
    {% else %}
      {% capture full_name %}{{ shareholder.name }}{% endcapture %}
    {% endif %}
  
    {% capture display %}display_{{ shareholder.id }}{% endcapture %}
    {% ic %}{% input custom.[display].to_display as:boolean %}{% endic %}
    {% if custom.[display].to_display != true %}
      {% ic %}*Enable {{ full_name }}*{% newline %}{% endic %}
    {% else %}
      
      {{ full_name }}{% newline %}
      
      **{% t "Number of shares" %}**	{{ shareholder.amount_of_shares | integer }}{% newline %}
      
      {% assign stock_type_from_sync = shareholder.custom.stock_type %}
      {% assign def_stock_type = "" %}
      {% case stock_type_from_sync %}
      {% when 1 %}
        {% assign def_stock_type = "Full ownership" %}
      {% when 2 %}
        {% assign def_stock_type = "Bare ownership" %}
      {% when 3 %}
        {% assign def_stock_type = "Usufruct" %}
      {% when 4 %}
        {% assign def_stock_type = "Indivisibility" %}
      {% endcase %}
    
      {% assign kind_of_shares = shareholder.custom.kind_of_shares | default:def_stock_type %}
       **{% t "Nature of shares" %}** {{ kind_of_shares }}{% newline %}
    
      {% if shareholder.custom.shares_classes != blank %}
        **{% t "Class of shares" %}** {{ shareholder.custom.shares_classes }}{% newline %}
      {% endif %}
    
      {% if shareholder.amount_of_votes != blank %}
        **{% t "Number of votes" %}** {{ shareholder.amount_of_votes }}{% newline %}
      {% endif %}
  
      <br/>
    {% endif %}
  {% endif %}
{% endfor %}
{% endstripnewlines %}
```

---

<div class="post-metadata">

**Author:** ![lieels01](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lieels01](https://community.silverfin.com/u/lieels01)\
**Post date:** [March 11, 2022, 10:35am UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254/3 "2022-03-11T10:35:10Z")

</div>

Hi @Jelena_Sutova

This is amaziing 🙂  
I have one additional question: I’d like to have the result with the names of shareholders in a dropdown instead of a boolean. Is this somehow possible?

So instead of {% input custom.[display].to\_display as:boolean%}

I’d need to use something like this, so the question is how do I et the actual names from the shareholders in the dropdown menu?  
{% input custom.[display].to\_display as:select options:"name | replace: ‘.’,’’ | replace: ’ ‘,’’ | remove:’-’ " %}

---

<div class="post-metadata">

**Author:** ![Jelena\_Sutova](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/jelena_sutova/32/599_2.png) [@Jelena\_Sutova](https://community.silverfin.com/u/Jelena_Sutova)\
**Post date:** [March 11, 2022, 3:57pm UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254/4 "2022-03-11T15:57:13Z")

</div>

@lieels01

I have updated the code:

Part 1: Creating the list of shareholders  
In this part - a list of shareholders is created: names and ids.

Part 2: Selecting shareholder from dropdown

Part 3: Display of data for selected shareholder  
Displaying data for selected shareholder based on id.

Please let us know if this works for your case.

```auto
{% comment %}Part 1: Creating the list of shareholders{% endcomment %}
{% for shareholder in period.shareholders %}
  {% if shareholder.persisted %}

    {% comment %}Assigning the type of the shareholder - "legal" or "nature"{% endcomment %}
    {% assign default_type = "" %}
    {% if shareholder.custom.represented_by_name != blank %}
      {% assign default_type = "legal" %}
    {% else %}
      {% assign default_type = "nature" %}
    {% endif %}
    {% assign type = shareholder.custom.type | default:default_type %}
    
    {% if type == "nature" %}
      {% assign words = shareholder.name | split: ' ' %}
      {% assign lastname = "" %}
      {% assign shareholder_first_name = "" %}
      {% for word in words %}
        {% if forloop.last %} {% comment %}correct for syncs like adminis{% endcomment %}
          {% assign shareholder_first_name = word %}
        {% else %}
          {% assign lastname = lastname | append:" " | append:word %}
        {% endif %}
      {% endfor %}
      {% capture shareholder_last_name %}{{ lastname | strip }}{% endcapture %}
      {% assign first_name = shareholder.custom.first_name | default:shareholder_first_name %}
      {% assign last_name = shareholder.custom.last_name | default:shareholder_last_name %}
      {% capture full_name %}{{ first_name }} {{ last_name }}{% endcapture %}
    {% else %}
      {% capture full_name %}{{ shareholder.name }}{% endcapture %}
    {% endif %}
  
    {% comment %}Creating list of shareholders to display in dropdown{% endcomment %}
    {% assign shareholders_options = shareholders_options | append:full_name | append:"|" %}
    {% assign shareholders_option_values = shareholders_option_values | append:shareholder.id | append:"|" %}
  
  {% endif %}
{% endfor %}

{% comment %}Part 2: Selecting shareholder from dropdown{% endcomment %}
{% input custom.shareholders_option.to_select as:select options:shareholders_options option_values:shareholders_option_values %}

{% comment %}Part 3: Display of data for selected shareholder{% endcomment %}

{% if custom.shareholders_option.to_select != blank %}
  {% stripnewlines %}
  {% for shareholder in period.shareholders %}
    {% if shareholder.persisted %}
        {% if shareholder.id == custom.shareholders_option.to_select %}
  
          **{% t "Number of shares" %}**	{{ shareholder.amount_of_shares | integer }}{% newline %}
          
          {% assign stock_type_from_sync = shareholder.custom.stock_type %}
          {% assign def_stock_type = "" %}
          {% case stock_type_from_sync %}
          {% when 1 %}
            {% assign def_stock_type = "Full ownership" %}
          {% when 2 %}
            {% assign def_stock_type = "Bare ownership" %}
          {% when 3 %}
            {% assign def_stock_type = "Usufruct" %}
          {% when 4 %}
            {% assign def_stock_type = "Indivisibility" %}
          {% endcase %}
        
          {% assign kind_of_shares = shareholder.custom.kind_of_shares | default:def_stock_type %}
           **{% t "Nature of shares" %}** {{ kind_of_shares }}{% newline %}
        
          {% if shareholder.custom.shares_classes != blank %}
            **{% t "Class of shares" %}** {{ shareholder.custom.shares_classes }}{% newline %}
          {% endif %}
        
          {% if shareholder.amount_of_votes != blank %}
            **{% t "Number of votes" %}** {{ shareholder.amount_of_votes }}{% newline %}
          {% endif %}
        
      {% endif %}
    {% endif %}
  {% endfor %}
  {% endstripnewlines %}
{% endif %}
```

---

<div class="post-metadata">

**Author:** ![lieels01](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@lieels01](https://community.silverfin.com/u/lieels01)\
**Post date:** [March 14, 2022, 11:30am UTC](https://community.silverfin.com/t/shareholer-automatic-completion/2254/5 "2022-03-14T11:30:23Z")

</div>

Hi @Jelena_Sutova

This is perfect! thank you so much 🙂
