Calculated Value Controls can be used for a variety of purposes, some of the most common uses include:
- Displaying user profile values
- Formatting dates and times
- Calculated dates
- Calculated numbers
- Combining form field values together (inside & outside of repeating sections)
- Displaying other columns from lookup lists
- Conditionally populate a field value (e.g. If Status equals approved, then populate Approved By with Current User and Approved On with Current Date)
When using Current User of Current Date
If you are using the Current Date, Current User or Current Time references in a calculated value formula:
In the vast majority of cases you want to set the calculated value to only Recalculate on new mode as usually you are referencing the person who submitted the form or the date/time the form was originally submitted.
This ensures that the formula only runs on New Form submissions. If you recalculate on View or Edit Mode the Current User or Current Date/Time used in your formula will change as people view or edit the form.
Displaying user profile values
Using the userProfileLookup function you can display a selected person’s preferred name, department, title, work phone,work email, etc:
For complete instructions on how to use the userProfileLookup function view this tutorial.
Formatting dates and times
Both Date fields on Nintex forms and the Current Date reference display in the full date, time, and time zone format. To format dates to display differently you have to use the formatDate() function:
Or to format times, the DateTimeField is a Date and Time field on the form:
Or you can format both the date and time from a Date/Time field:
If you want to display the Current Date and Time in the same field, you will need to reference and format both fields in the Formula.
*Note, the + combines the references and the ” “ puts in a space between them
See the Nintex Forms formatDate formats tutorial for more formatting options.
If you are doing a calculation and displaying a date, you will usually need to combine the formatDate() function with your calculation. The dateAddDays() can be used to add days to a selected date field.
OR the dateAddDays() can be used to subtract days from a selected date field. Note that the second value in the dateAddDays() function can either be a field reference or a static number.
You can also use calculated fields to show the difference between two date fields, or the difference between the current date and a date field.
For number calculations, you can use the regular math operators (+, -, *, /).
To specify order of operation, use brackets.
Combining form field values together
You can combine multiple form field values together using the + operator.
You can add spaces or text in quotes.
Or runtime functions as well.
**Combining fields together is a good way to create a meaningful title for the form:
Creating a Calculated Title for Nintex Forms
Displaying information from linked lookup lists
List lookup fields on your form return the looked up item with both the items ID and then the value displayed in the dropdown box (usually the Title field for that item):
Use the parseLookup function to return the column value (true)
OR item ID (false)
You can display other field values from the item selected in the List lookup fields too. Use the lookup function with the format:
lookup(lookup list title, ‘ID’, named control, lookup column name to display)
In the example above the lists title that is being looked up is ‘Items List’ and the column in the Items List which we are displaying the value for is named ‘Price’.
Conditionally populating field values
You can conditionally populate a field value as well, for example if you want the title to be different for different request types. Use the If() function with the format:
If(condition to test, value if true, value if false)
You can nest if statement if there is more than one condition to test, format is:
If(condition1 to test, value if true, If(condition2 to test, value if true, value if false))
Populate a field conditionally
You can also populate a field conditionally, for example you can populate an Approved By field with the Current User and Approved On field with the Current Date if someone selects Yes on the Approve Request field on the form. This is a little more complicated because you would only want these fields populated once (not every time an approved item is edited). See the Get Current Person Date of person who completed form section tutorial (tutorial coming soon).