Choose an administrator

Hello, I was using this code to select directors or permanent representatives of companies. Can someone help me to adapt it with the new reconciliation “Legal Report - Shareholders/Associates & Managers / the Board of Directors”?

I would also like to be able to put “Mr./Ms.” according to gender.

Thank you for your help.

Sincerely

{% assign directors = period.directors %}

{% assign names = "" %}
{% assign values = "" %}
{% for person in directors %}
  {% assign default_type = "" %}
  {% if person.custom.represented_by_name != blank %}
    {% assign default_type = "legal" %}
  {% else %}
    {% assign default_type = "nature" %}
  {% endif %}
  {% assign type = person.custom.type | default:default_type %} 
  {% if type == "legal" %}
    {% assign names = names | append:person.custom.represented_by_name %}
    {% assign values = values | append:person.id %} 
  {% else %}
    {% assign names = names | append:person.custom.first_name | append:" " | append:person.custom.last_name %} 
    {% assign values = values | append:person.id %} 
  {% endif %}
  {% unless forloop.last %}
    {% assign names = names | append:"|" %}
    {% assign values = values | append:"|" %}
  {% endunless %}
    {% assign forloop_index = forloop.index0%}
  {% if person.id == custom.choosing.directors%}{{ names [forloop_index] }} {% endif%}
{% endfor %}


<br>
<br>

 {{ company.name }} {{ company.company_form }} 
 A l’attention de {% input custom.choosing.directors as:select options:names %}

Hi @THANAS

If your code worked before, that should still be the case. All these fields still have the same name in the database.

As for the gender, you can add it in front of the name, but this changes the options and will break the existing input. The code actually mentions “values”, this was intended to use as option_values, by using option_values you can change the options without breaking the input.

So as not to break you current input, you would need to use the current options (names) as option_values, and then create new options with the genders attached.
I’ve taken the liberty to also add a basic translation, but this is not necessary if you would only use 1 language.

{% assign directors = period.directors %}

{% t= "Mr" fr:"Monsieur" %}
{% t= "Mrs" fr:"Madame" %}

{% assign names_values = "" %}
{% assign names_options = "" %}
{% assign values = "" %}
{% for person in directors %}
  {% assign default_type = "" %}
  {% if person.custom.represented_by_name != blank %}
    {% assign default_type = "legal" %}
  {% else %}
    {% assign default_type = "nature" %}
  {% endif %}
  {% assign type = person.custom.type | default:default_type %} 
  {% comment %}Gender is stored as "man" or "woman", add some logic to convert it{% endcomment %}
  {% assign gender = person.custom.applicable_gender %}
  {% if gender == "man" %}
    {% capture gender_address %}{% t "Mr" %} {% endcapture %}
  {% elsif gender == "woman" %}
    {% capture gender_address %}{% t "Mrs" %} {% endcapture %}
  {% else %}
    {% assign gender_address = "" %}
  {% endif %}
  {% if type == "legal" %}
    {% assign names_values = names_values| append:person.custom.represented_by_name %}
    {% assign values = values | append:person.persistent_id %} 
    {% assign names_options = names_options | append:gender_address| append:person.custom.represented_by_name  %}
  {% else %}
    {% assign names_values = names_values| append:person.custom.first_name | append:" " | append:person.custom.last_name %} 
    {% assign values = values | append:person.persistent_id %} 
    {% assign names_options = names_options | append:gender_address | append:" " | append:person.custom.first_name | append:" " | append:person.custom.last_name %}
  {% endif %}
  {% unless forloop.last %}
    {% assign names_values = names_values | append:"|" %}
    {% assign values = values | append:"|" %}
    {% assign names_options = names_options | append:"|" %}
  {% endunless %}
    {% assign forloop_index = forloop.index0%}
  {% if person.persistent_id == custom.choosing.directors%}{{ names_options [forloop_index] }} {% endif%}
{% endfor %}


<br>
<br>

 {{ company.name }} {{ company.company_form }} 
 A l’attention de {% input custom.choosing.directors as:select options:names_options option_values:names_values %}

You may notice I also replaced persion.id with person.persistent_id.
This is just a good practice, as the id changes every period, while persistent_id remains the same.
(as the name implies :wink: )

Hope this helps,
Kind regards,

Romy

Hi @Romy_Vermeeren,

Many thanks for your help.

I thought that with the change in reconciliation it would have changed the links.

It’s a regret that we don’t have the gender for the permanent representative (this is a request I made to support)

Is it also possible to take over the function of the administrator?

Kind regards,

Hi @THANAS

No worries, we’re happy to help.
The main difference you’ll notice code-wise with the new templates, is that you can now access results from them. (you can find an overview here!)

The code for this template is open source, so if you open the reconciliation text on the “template tab” in your Silverfin environment, you can find the name of any input. Function is person.custom.function, but note that it has a default value as well, which isn’t stored in the database. You’d have to repeat the logic that was used to come to this default.

Kind regards,
Romy