Recent

Nintex Forms Calculated Value Examples

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:
NF-Calculated-Value-Examples-16-2
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.
NF-Calculated-Value-Examples-16-3

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:
NF-Calculated-Value-Examples-16-1
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:
NF-Calculated-Value-Examples-16-4

Or to format times, the DateTimeField is a Date and Time field on the form:
NF-Calculated-Value-Examples-16-5

Or you can format both the date and time from a Date/Time field:
NF-Calculated-Value-Examples-16-6

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
NF-Calculated-Value-Examples-16-7

See the Nintex Forms formatDate formats tutorial for more formatting options.


Calculated dates

dateAddDays()

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.
NF-Calculated-Value-Examples-16-9

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.
NF-Calculated-Value-Examples-16-11

dateDiffDays()

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.
NF-Calculated-Value-Examples-16-10


Calculated numbers

For number calculations, you can use the regular math operators (+, -, *, /).
NWF-Calc-Value-Examples-16-8

To specify order of operation, use brackets.
NWF-Calc-Value-Examples-16-9


Combining form field values together

You can combine multiple form field values together using the + operator.
NWF-Calc-Value-Examples-16-1
You can add spaces or text in quotes.
NWF-Calc-Value-Examples-16-2
Or runtime functions as well.
NWF-Calc-Value-Examples-16-3

**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):
NWF-Calc-Value-Examples-16-5

parseLookup()

Use the parseLookup function to return the column value (true)
NWF-Calc-Value-Examples-16-6
OR item ID (false)
NWF-Calc-Value-Examples-16-7

Lookup()

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)
NWF-Calc-Value-Examples-16-4
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

If()

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)
NWF-Calc-Value-Examples-16-10

If(If())

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))
NWF-Calc-Value-Examples-16-11

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).

About Nick Hurst (84 Articles)
SharePoint and Nintex developer who strives to find easy to deploy and maintain solutions for business problems.

4 Comments on Nintex Forms Calculated Value Examples

  1. Hi Nick, I have a form with 3 panels. All three have mandatory fields. How can I disable the mandatory fields in panel 2 and 3 so the requester can submit his request using panel 1?

    Like

  2. Thank you for the article, it was really helpful. I have a question though, how do I now ensure that my list lookup and calculated values are stored in my “primary” SharePoint list on submission. When I open the submitted form i see the details but they are not in the SharePoint list.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: