Use of the user method in export styles

Hello,

It’s my first post here, so if I didn’t use proper community guidelines, please let me know.

My problem:

I want to use data from an input variable in an reconciliation on the frontpage in my export style.
However, if there isn’t anything stored in the variable I want to use the current users name (which is the default for the input).

I have tried using “user.name” both as default in the reconciliation and as a new value in the export style, but this doesn’t seem to work.
I know the default isn’t actually stored in the variable, but using “assign” also didn’t work.

What am I doing wrong here? Any help is greatly appreciated.

This is the code in the export style:

{% assign contact_name = period.custom.contact.name %}
{% if contact_name == "" %}{% assign contact_name = user.name %}{% endif %}

This is the code in the reconciliation:

<table class="usr-width-100">
  <thead>
    <tr>
      <th class="{{ all_borders_class }} usr-align-center" colspan="4"><b>INSTELLINGEN BRIEF GRIFFIE</b></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="usr-width-25 {{ all_borders_class }}"><b>Contactpersoon</b></td>
      <td class="usr-width-25 {{ all_borders_class }}">{% input period.custom.contact.name as:text default:user.name assign:contact_name %}</td>
      <td class="usr-width-25 {{ all_borders_class }}"><b>Partner</b></td>
      <td class="usr-width-25 {{ all_borders_class }}">{% input period.custom.partner.name as:select options:partners %}</td>
    </tr>
    <tr>
      <td class="usr-width-25 {{ all_borders_class }}"><b>E-mail</b></td>
      <td class="usr-width-25 {{ all_borders_class }}">{% input period.custom.contact.mail as:text default:user.email assign:contact_email %}</td>
      <td class="usr-width-25 {{ all_borders_class }}"><b>Ondernemingsrechtbank</b></td>
      <td class="usr-width-25 {{ all_borders_class }}">{% input period.custom.rpr.type as:select options:court_types %}</td>
  </tr>
  </tbody>
</table>

Hi @Jasper and welcome to the Community!

No worries, your post perfectly follows the guidelines.

It’s not possible to access the user drop in the style settings.
Coding options in this section are limited for a multitude of reasons.

In this case, you can overcome this by adding the contact_name to a result in your reconciliation text.
You’ll then be able to print that result on the cover page.

e.g. in the reconciliation you could add the following:

{% result "contact_name_export" contact_name %}

And on the cover page you should be able to print that result, like this:

{{ period.reconciliations.[handle of your reconciliation text].results.contact_name_export }}

Hope that helps!

Kind regards,
Romy

Hey @Romy_Vermeeren,

Thank you for the solution, this works great.

In general, would you say using results is the best practice for letting variables flow through to the export styles? Or do you only use them in these cases, when you can’t access them directly?

Hi @Jasper

In general, I’d say yes. The only exception could be accessing information directly on the company or period drop.
If you create a result on reconciliation level and you ever want to make an update to that code, you don’t have to worry about updating the code in the style. (or risk forgetting to update it :grimacing:).

By using results you can keep all of the logic in one place, which comes in especially handy when dealing with defaults on inputs for example.

Just make sure you don’t change the name of the result :bulb:

Kind regards,
Romy