Expression Samples

Basic Expressions

Scenario
Expression
Return Value Type
Use value from the txt1 field from the query DataTable1 that is used in Form1.
{Form1}.Query("DataTable1")["txt1"]
Text
Use value from imported data models.
{Form1}.Query("ref:ns0/Form1")["Field1"]
Integer
Retrieve workflow metadata, such as the workflow instance ID. This example returns the current workflow ID using the Wf syntax.
Wf.workflowInstanceId
Integer
Boolean expression, query if a numeric text box value is greater than 10, and the text box field type is int.
{Form1}.Query("DataTable1")["Num1"] > 10
Boolean
Boolean expression, query if a combo selected item text equals a value.
{Form1}.Query("DataTable1")["localization"] = "en-UK"
Boolean
Use SQL statement.
{SQL: select top 1 fldid from tblitems}
N/A
Use activity properties.This example uses the "CreatedAt" attribute to return the date an activity was created.
{Form1}.CreatedAt
DateTime
Use an expression in a message field.
Dear User, Please note that the employee { {Form1}.CreatedBy.DisplayName }
Text
Use runtime values in forms. This example returns the user's display name.
rt.CurrentUser.DisplayName
Text


Intermediate Expressions

Scenario
Expression
Return Value Type
Check if an activity was created.
{ActivityX}<>NULL
Boolean
Get the number of times an activity was created in a workflow instance (only when the activity is not null).
{ActivityX}.Scope().Count()
Integer
Concatenate strings.
{Form1}.Query("DataTable1")["txt1"] +
{Form1}.Query("DataTable1")["txt2"]
Text
Use a SQL expression with process values.
ToInt32({SQL: select claimValue from claims where flddate = { {Form1}.Query("DataTable1")["RequestData"] } })
According to casting. The default is String.
Check if all the tasks for an activity were completed.
{Task1}.Tasks.All(IsCompleted)
Boolean
Query response XML using XPath, and obtain x value from an XML.
XPathSelectValue({Consumer1}.RequestXml,"//*[local-name()='x']")
OR
XPathSelectElement({Consumer1}.RequestXml,"//*[local-name()='x']").Value

In cases of collections:
XPathSelectElements({Consumer1}.RequestXml,"//*[local-name()='x']").First().Value
Text
To access a multiple records form, use the reserved word "Row" following the index number of the row we want to access.
Row(0) indicates the first row.
Row(x) indicates a specific row.
{form1}.Query("DataTable1").where(Field("txt1") = "John")

{form1}.Query("DataTable1").Row(0).field("txt1")
{form1}.Query("DataTable1").Row(3).field("txt1")

To display the content of the last row:
{form1}.Query("DataTable1").Last().field["txt1"]
Text
Use an IIF expression. This example returns text if this is the fifth iteration of an activity.
IIF( {Activity}.scope().count() =5, "This is the fifth iteration", "")
Text
Get advanced parameters from runtime.
The first example returns the headeritemKey parameter in the current parameter HttpHeader.
The second example returns the ItemID parameter in the current runtime query string.
rt.httpRequest.Headers["headeritemKey"]

rt.httpRequest.QueryString["ItemID"]
Integer
Add a line break to an expression.
<your first line> + string.Concat(Convert.ToChar(13),Convert.ToChar(10)) + <your second line>
N/A
Verify that all recipients have approved a task.
{ Task1 }.Tasks.Where(Query("DefaultView").field("approval")==true).count()={ Task1}.Tasks.count()
Boolean
Sum the column of a grid that is a numeric value.
{Form1}.Query("GridItems").Sum(Field("Amount"))
Integer
Execute a SQL statement that returns a scalar.
{SQL: select fldEmpName from tblEmployees where fldEmployeeId = 724}
Primitive


Advanced Expressions

Scenario
Expression
Return Value Type
Get values from the last iteration of a loop, and return an empty string if it is the first loop.
IIF({Task1}=NULL, null, TryElse({Task1}.Scope().At({Task1}.Scope().Count()-1).Query("DefaultView")["txt1"],0))
Text
When you loop on a form with a grid and want to take only one row value at a time, and only if the row is check box is selected.
{MainForm}.Query("GridItems").where(Field("chkSelectedTender") = true).Select(Field("fldid")).At({Activity2}.Scope().Count()-1)
Depends on the field content
Count the number of rows in a grid form that meet a certain condition.
{mainForm}.Query("GridItems").where(Field("chkSelected") = true).Count()
Integer
Search the response for the first available user in the Web Service Consumer response.
{Activity1}.ReturnValue.Where(STATUS = “available”).First()
Text
Add multiple attachments to a message from a grid.
{Activity Name}.Query("Grid Name").Select(field("AttachmentFieldName"))
Array of Attachments
Constructor invocation.
new Uri("http://pnmsoft.com")
Uri object
Array creation and initialization.
new String[] { "a", "b", "c"}
Array of strings
Display an expression result in String format to two decimal places.
ToSingle({Prepare and Submit Expense Claim}.Query("ref:FormViews/ExpenseLines").Select(Field("VAT")).Sum()).ToString("000.00")
ToSingle({Form5}.Query("Form5")["Age"]).ToString("000.00")

String
Find all user IDs of users that submitted a given task.
Join({Task1}.Scope().SelectMany(Tasks).where(IsCompleted).Select(UpdatedBy.UserId),";")
Array of user IDs
Return the last day of the current calendar year.
ToDateTime({SQL: SELECT convert(varchar,DATEADD(yyyy, { SQL: SELECT DATEPART(yyyy, { Now() }) } - 1899, -1), 103) + ' 12:00 AM'})

Date
About this Article
  • Created: 05/22/2017 4:59 am EDT
  • Last updated: 09/03/2017 7:05 am EDT
In This Article