# Smart Fields

![](https://tawk.link/61dd64c2b84f7301d32a6e5b/kb/attachments/IEZauU_yH6.png)

### 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:

**{$currentDate | date:'\[format]':'\[timezone]':'\[style]'}**

**{$currentTime | date:'\[format]':'\[timezone]'}**

**format \[optional]** - output format using language code - Examples: en-US, en-GB, fr-FR, de-DE, pl-PL, es-ES, it-IT | **Default: 'en-US'**

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

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

**style \[optional]** - date display style | **Default: Auto selected - depends on "format"**

```
'full', 'long', 'medium', 'short'
```

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

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

Examples for date:
{$currentDate} ---> 4/28/2023
{$currentDate | date:'en-US'} --->  4/28/2023 
{$currentDate | date:'de-DE'} --->  28.4.2023 
{$currentDate | date:'de-DE':'Europe/Berlin'} --->  28.4.2023
{$currentDate | date:'de-DE':'Pacific/Pago_Pago'} --->  27.4.2023 (Timezone can affect date)
​{$currentDate | date:'de-DE':'Pacific/Kiritimati'} ---> 29.4.2023 (Timezone can affect date)

{$currentDate | date:'en-US':'UTC'} ---> 5/8/2025
{$currentDate | date:'en-US':'UTC':'short'} ---> 5/8/25
{$currentDate | date:'en-US':'UTC':'medium'} ---> May 8, 2025
{$currentDate | date:'en-US':'UTC':'long'} ---> May 8, 2025
{$currentDate | date:'en-US':'UTC':'full'} ---> Thursday, May 8, 2025

{$currentDate | date:'de-DE':'UTC'} ---> 8.5.2025
{$currentDate | date:'de-DE':'UTC':'short'} ---> 08.05.25
{$currentDate | date:'de-DE':'UTC':'medium'} ---> 08.05.2025
{$currentDate | date:'de-DE':'UTC':'long'} ---> 8. Mai 2025
{$currentDate | date:'de-DE':'UTC':'full'} ---> Donnerstag, 8. Mai 2025


// Use addDays on currentDate
{$currentDate | addDays:3 | date:'en-US'} --->  Adds 3 days to currentDate and use'en-US' format
{$currentDate | addDays:7 | date:'de-DE'} --->  Adds 7 days to currentDate and use'de-DE' format
```
