Genpact Cora Knowledge Center

Support

Expression Samples

Starting with V10.0, Cora SeQuence has been renamed to Cora Orchestration.

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"] String
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 on which an activity was created.
{Form1}.CreatedAt DateTime
Use an expression in a message field. Dear User, Please note that the employee { {Form1}.CreatedBy.DisplayName } String
Use runtime values in forms. This example returns the user's display name. rt.CurrentUser.DisplayName String
Access the properties of an attachment, regardless of where it is stored.
Available from V9.2
{Form1}.Query("UACT1").Include("AttachmentField") String
Retrieve the full content of the body of the email {ICM Email Listener}.Email.PreviewBodyHtml String
Retrieve only the HTML text without images, embedded images, or base64 images {ICM Email Listener}.Email.BodyHtml String
Check if a Task is already fetched, and if fetched, then retrieve all the details of the user who has fetched it.
Available from V10.2
{Task1}.FetchedBy Object
For example: (PNMsoft.Sequence.Obs.UserView)
Returns Null if task is not fetched.
Check if a value exists in a list of values.
Available from V10.4
NOTE
! operator is not supported with In and Not In operators.
{Form1}.Query("query1")["Field1"] In ("value1", "value2", "value3")
OR
{Form1}.Query("query1")["Field1"] Not In ("value1", "value2", "value3")
Boolean
For example, the In expression returns True if value exists in the list, and returns False if value doesn't exist.


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"]
String
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
String
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"]
String
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", "") String
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
Calculate a date based on the working days of a configured calendar. CalendarDateAdd(rt, wf.CreatedBy.CalendarId, "dd", 10, Now()) DateTime
Check if the email received is an autoreply.
Available from V10.4
{Email Listener}.IsAutoReply Boolean


Advanced Expressions

Scenario Expression Return Value Type
Extract the user readable text  as a string from an HTML content. Remove all HTML elements, CSS and Script sections. Break lines are not retained.
Available from V10.6
StripHTML(<HTML-String>)
String
Convert a JSON structure into key or value array.
Available from V10.6
JsonValue(ToString("{name:" + '"' +"John" + '"' +", age:31, city:" + '"' +"New York" + '"' +"}"))
Array of JsonValue objects (key, value)
Get the value from a JSON structure by key.
Available from V10.6
JsonValue(ToString("{name:" + '"' +"John" + '"' +", age:31, city:" + '"' +"New York" + '"' +"}")).age.value
Object
Create a JSON string from a JSON object, exclude the null values.
Available from V10.6
JsonString(JsonValue(ToString("{name:" + '"' +"John" + '"' +", age:31, city:null}")))
Line string
For example: {"name":"John","age":31}
Create a JSON string from a JSON object, exclude the null values, apply automatic indentation.
Available from V10.6
JsonString("Indented", JsonValue(ToString("{name:" + '"' +"John" + '"' +", age:31, city:null}")))
String
For example:
{
  "name": "John",
  "age": 31}
Create a JSON string from a JSON object, keep the null values, apply automatic indentation.
Available from V10.6
JsonString("KeepNullValues,Indented", JsonValue(ToString("{name:" + '"' +"John" + '"' +", age:31, city:null}")))
String
For example:
{
  "name": "John",
  "age": 31,
  "city": null}
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)) String
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() String
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
Convert special characters to the escaped representation. Uri.UnescapeDataString(Uri.EscapeDataString("Test%%")) String
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

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 HTML HTML with workaround
<style>
.aa
  {
    color: green;
  }
</style
<style>
.aa
  { “{“ }
    color: green;
  }
</style