Smart Fields

Smart fields use a special tag that starts with "$". They cannot be provided by a user in the form. Those fields are build or calculated based on existing nonsmart regular fields.

Smart Fields to calculate values

Labor: {labor} USD
Parts: {parts} USD
Total: {$ labor + parts} USD
Total + Tax: {$ (labor + parts) * 1.22}

You can use smart field to do simple and advanced calculations based on provided user form input.

Make sure that you pick “NumberField” in form customization to prevent users from using text instead of numbers for fields that you want use for your calculations.

Smart Fields Numbers vs Strings

If you want to accept strings and convert them into numbers for further calculations (useful if you integrate with the external system) you can use the special syntax within smart fields like : +[fieldname]. Example:

Assuming:
field1: "2",
field2: "5"
field3: 2,
field4: 5

{$ field1 + field2 } ==> 25
{$ field3 + field4 } ==> 7

{$ +field1 + +field2 } ==> 7 
// Converts "2" into Number 2 and "5" into 5

Use Special Filters to modify results

Smart Fields for conditions

You can use conditions to output element based on value provided from different field (from user)

General Condition Schema:

{$ [CONDITION] ? [TEXTIFTRUE] : [TEXTIFFALSE]}

Examples:

{$ FIELDNAME == 'VALUETOCOMPARE' ? 'textIfTrue' : 'textIfFalse'}
{$ FIELDNAME != 'VALUETOCOMPARE' ? 'textIfTrue' : 'textIfFalse'}
{$ FIELDNAME > NUMBERTOCOMPARE ? 'textIfTrue' : 'textIfFalse'}
{$ FIELDNAME < NUMBERTOCOMPARE ? 'textIfTrue' : 'textIfFalse'}

Supported operators:

== (Equal),
!= (Not Equal),
> (More Than)
< (Less Than)
&& (And)
|| (OR)

Example #1

Name: {name}
Surname: {surname}
Sex: {sex}
Full Name: {$ sex == 'woman' ? 'Mrs.' : 'Mr.'} {name} {surname}

Example #2

Name: {name}
Age: {age}
Status: {$ age > 18 ? 'Adult' : 'Underage'}

Special Smart Fields

Show Current Time & Current Date with Format & Timezone

You can display current time or date using special smart field.

It supports two optional parameters:

{$currentTime>[format]>[timeZone]}

{$currentDate>[format]>[timeZone]}

format [optional] - output format using language code (12 hours vs 24 hours etc.) - Examples: en-US, en-GB, fr-FR, de-DE, pl-PL, es-ES, it-IT | Default: 'en-US'

timeZone [optional] - timezone in Intl format - Examples: America/Chicago, Europe/Berlin, Europe/Warsaw, Europe/Rome | Default: 'Universal' UTC Timezone See list of Available Timezones:

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

If incorrect format / timezone will be provided Documentero will use default values.

Examples for time:
{$currentTime} ---> 6:57:14 PM 
{$currentTime>en-US} --->  6:57:14 PM 
{$currentTime>de-DE} --->  18:57:14 
{$currentTime>de-DE>Europe/Berlin} --->  20:57:14 
{$currentTime>de-DE>America/Chicago} --->  13:57:14 
{$currentTime>de-DE>America/New_York} --->  14:57:14 
{$currentTime>en-US>America/Chicago} --->  1:57:14 PM
{$currentTime>en-US>America/New_York} --->  2:57:14 PM

Examples for date:
{$currentDate} ---> 4/28/2023
{$currentDate>en-US} --->  4/28/2023 
{$currentDate>de-DE} --->  28.4.2023 
{$currentDate>de-DE>Europe/Berlin} --->  28.4.2023

Template Variable Assignments

Sometimes you want to calculate some value based on data input and reuse it across the document. You can do that using assignments within smart fields then you can use assign value withing Smart Fields or Smart Sections Multiple Times

Cost of labor: {labor} USD
Cost of parts: {parts} USD

Total Cost: {$ total = labor+parts } USD

Total Cost + Tax: {$ total * 1.22 } USD (Including 22% Tax)

{#$ total > 1000 }
Warning! Your total net cost exceeds 1000 USD
{/}

Last updated