As no company is a-like, we've built a feature called SmartString which help clients to make complex exports possible. It allows for IF statements to be incorporated into all export formats or convert data into any desired format. Please note that this feature is meant for administrator users of SRXP with a little bit of experience with our Exports.

The name SmartStrings refers to a smart and custom friendly  'String'. A String is a term often used for in programming languages to state that something is of type Text. It can also be understood as a sequence of characters that together form a Text. In this case, we made this String/Text smart. Using it allows for anyone without any coding experience to build complex exports.

One could compare it with the Excel Functions we already support in the CSV 2.0. export format but these only work on Excel/CSV like export formats and really depend on what is exported in some column. 

Let's see how to use the SmartString feature to make complex exports. We do this by handling different scenarios which could closely resemble your specific use case for this feature.

Using Filter

The SmartString contains a hidden feature called filters. Filters can be seen as output changers, they can convert the result of some output. They are triggered by the pipe character: |
So, 

 {{ report.account.free_1|upper }}

This will convert any output of the first part (report.account.free_1) to be converted into all caps.

The available filters are: 

  • date - allows for formatting of dates.
{{ report.submit_date |date("m/d/Y") }} => '10-02-2017'

// Pro tip, output the current date with "now":
{{ "now" |date("m/d/Y") }} => '10-03-2017'
  • date_modify
{{ report.submit_date|date_modify("+1 day")|date("m/d/Y") }} => '10-01-2017'
  • number_format
{{ 38100.333|number_format(2, ',', '.') }} => 38.100,333

The first '.' is the decimal separator, the second is the thousand separator.  In this way you can support any number format that your financial system requires.

  • upper - Will convert any text to all caps.
  • lower - Will convert any text to lower case.
  • join - Will convert a list into text.
  • first - Outputs the first character of the input text.
  • last - Outputs the last character of the input text.
  • capitalize - Will convert the first character of every sentence into capitalized text, such that is nicely readable.
  • length -  Outputs the length of any text.
{{ string [start:length] }} => 'output'
{{ '12345' [0:3] }} => '123'
{{ '12345' [1:4] }} => '2345'
  • slice - Extracts a portion of a sequence, mapping or string. 
  • reverse - Reverses the input text.
  • title - Make a title representation of given text.
  • trim - Can trim any character from the start of end of input text.
{{ '  An expense description.  '|trim }} => 'An expense description.'

{{ '  An expense description.'|trim('.') }} => '  An expense description.'

{{ '  An expense description.  '|trim(side='left') }} => outputs 'An expense description.  '

{{ '  An expense description.  '|trim(' ', 'right') }} => '  An expense description.' #}
  • merge - Merges an array
  • default - Can provide a default value if the current value is not found or defined.

Very useful for when a there is no payment method on the expense (which is the case for mileages, duties and timesheets).

{{ expense.payment_method.code |default('1234') }} => '  An expense description.' #}
  • export_currency - Will convert an amount to export currency using the exchange of the expense. Make note that you can only use this on an expense level, as the exchange rate is per expense and not per report.
{{ amount.amount |export_currency }}
  • inc_vat - Will show the expense amount including VAT. The amount will be shown excluding VAT as default. You can't use this string for the report title. 
{{ amount.amount |inc_vat }}

The list of test operators

In this Section we will provide information about the different operators we support in the SmartStrings feature

-----------------------------------------------------------------------------------------------------------------------------
checks if A and B are equal

  • ==         
{% if A == B %} ... {% endif %}

-----------------------------------------------------------------------------------------------------------------------------
checks if A and B are equal

  • is
{% if A is B %} ... {% endif %} 

-----------------------------------------------------------------------------------------------------------------------------
Reverses the result of B

  • not
{%if A is not B %} ... {% endif %}

-----------------------------------------------------------------------------------------------------------------------------
Checks is A is smaller than B - only works for numeric values.

  • <
{% if A < B %} ... {% endif %}

-----------------------------------------------------------------------------------------------------------------------------
Checks is A is greater than B - only works for numeric values.

  • >
{% if A > B %} ... {% endif %}

-----------------------------------------------------------------------------------------------------------------------------
Checks is A in B

  • in
{% if A in B %} ... {% endif %}

This can work for example, when is A = 1 and B = [1,2,3]

{% if 1 in [1,2,3] %} ... {% endif %}      => true
{% if 'abc' in 'abcd' %} ... {% endif %}   => true
{% if 'z' in 'abcd' %} ... {% endif %}     => false

-----------------------------------------------------------------------------------------------------------------------------
Checks is A in B

  • starts with
{% if expense.project.code starts with 'PROJECT-1234-' %} 
    {{ report.account.free_1 }}
{% endif %}

Very useful when you want to use some value in SRXP only for the projects of some type. If you have defined your projects systematically, you will be able to do this.

Did this answer your question?