Nintex - Using Inline Functions PDF
Nintex - Using Inline Functions PDF
Contents
Introduction ........................................................................................................................................ 2
Inline function to replace text within a workflow text variable. ........................................................ 2
Inline function to correctly format a date/time value. ....................................................................... 5
Using an inline function to determine the difference in days between 2 date variables .............. 7
Introduction
This tutorial will show examples of how to correctly use various workflow inline functions. It applies
equally to Nintex Workflow 2007 and 2010, despite the screenshots showing only Nintex Workflow
2010.
Examples will include how to correctly format inline functions, as well as explaining the use of
{TextStart} and {TextEnd} to split inline function parameters.
Inline functions can be used within any action that has an Insert Reference button.
fn-Replace
Replaces a section of text in a larger string.
Example
fn-Replace({WorkflowVariable:Text},xxx,{ItemProperty:Title})
Arguments
Text The text to modify.
Old value The text to search for and replace.
New value The text to replace Old value with.
The first step is to create a simple text string to edit. This can be done using a ‘Build dynamic string’
action.
Another ‘Build dynamic string’ action can then be used to replace the contents of the text variable.
In this case ‘123’ will be replaced with ‘onetwothree’.
fn-Replace({WorkflowVariable:text},{TextStart}123{TextEnd},{TextStart}onetwothree{TextEnd})
The {TextStart} {TextEnd} tokens are used to ensure any values between these tokens will not
interfere with the inline function syntax. For example you can use special characters between these
tokens such as ‘/()@#$^ and they will correctly be replaced rather than resulting in an error when
the workflow attempts to evaluate the inline function.
The text variable can then be used in any other action or logged to the history list to confirm it is
correct.
Date/Time variables are by default in the format 21/11/06 10:30:23 AM. However, often within a
workflow the designer will need to know the current day or month a date value represents. The
inline function fn-FormatDate() can be used to achieve this.
fn-FormatDate
Represents a date time value in text of a specific format.
Example
fn-FormatDate({WorkflowVariable:MyDate}, d)
Arguments
To format a date, the date must first be stored within a workflow date variable or referenced
directly from a SharePoint date/time field. In this example, a date variable will be used and
configured using the ‘Calculate Date’ action.
The above configuration will store the date 17/03/2011 4:25 AM into a workflow date variable
named ‘date’.
A ‘Build dynamic string’ action can then be used to format the date as required.
fn-FormatDate({WorkflowVariable:date}, MMMM)
fn-FormatDate({WorkflowVariable:date}, ddd)
Return time in 24 hour format including current day, month and year:
Adding to this example you can also use an inline function to determine the difference between 2
date variables.
Example:
fn-DateDiffDays
Determines the number of days between two dates.
Example
fn-DateDiffDays({WorkflowVariable:StartDate}, {WorkflowVariable:EndDate})
Arguments
Start date The starting date and time to calculate the difference between.
End date The end date and time to calculate the difference between.
The following inline function will return the difference between the dates in days.
fn-DateDiffDays({WorkflowVariable:date1}, {WorkflowVariable:date2})
The convert value action can then be used to convert this text result to a number.
Example output: