Genpact Cora Knowledge Center


Expression Samples

Basic Expressions

ScenarioExpressionReturn 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.workflowInstanceIdInteger
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"] > 10Boolean
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 on which an activity was created.
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.DisplayNameText
Access the properties of an attachment, regardless of where it is stored.
Available from V9.2

Intermediate Expressions

ScenarioExpressionReturn Value Type
Check if an activity was created.{ActivityX}<>NULLBoolean
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"] + 
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']")

In cases of collections:
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")


To display the content of the last row:
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.

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
Calculate a date based on the working days of a configured calendar.
CalendarDateAdd(rt, wf.CreatedBy.CalendarId, "dd", 10, Now())

Advanced Expressions

ScenarioExpressionReturn 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 Uri("")Uri object
Array creation and 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")
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'})


Code Editor Limitation

Inline styles: Because Cora SeQuence identifies {} as part of an expression, to create a valid HTML code for inline styles, you need to add an additional tag to your code— “{“ } .
For example, see below how to set up a style that applies the color green to your text:

Regular HTMLHTML with workaround
    color: green;
  { “{“ }
    color: green;