You can use calculated fields to expand the data model using configured or captured data. For instance, you might want to fill calculated fields based on data captured in other fields.
Calculated fields allow you to write short scripts to extract any Clio Operate data. Using calculated fields is ideal for document generation or template administration. As well as extracting the data, you can perform basic operations on it, like comparing data, returning a value based on the comparison, and then formatting it. For example, you can calculate a participant's age and return this in words rather than numbers. You can also reference other calculated fields from within a field.
Using this page. Each tab covers one part of the work: setting up fields, writing expressions, looking up a function, working with lists, using fields in documents, script functions and debugging. To find a function or an operator, type in the Search the whole page box. It searches the tables on every tab at once. Above each table, use the dropdown to show one category.
🧭 Overview
| Term | Definition |
|---|---|
| Calculated field | You can use expressions and scripts to reference, build, or retrieve data to use as a value. |
| Expression | An expression is a function used to get a piece of data, like a claimant's last name. |
| Script | A script is a series of expressions forming a more complex data retrieval and formatting function. For example, getting task completed dates from a matter and presenting them as a list in a document formatted with ordinals and the month name spelt out: the 3rd of March. |
Creating a Calculated Field
Before you start
- You need the
core.modellersystem permission to create, edit and delete calculated fields. - You can create calculated fields in any Data Composer explorer. For a work type, navigate to Modeller > Work Types > {Your WorkType} > Data Composer. For every place where Data Composer is available, see the article Data Composer.
- Decide which level of the work type hierarchy to add the field at. Work types are hierarchical: to apply a field to a parent type such as 'matter' and all its child types, add it at the matter level. To use it on one work type only, add it to that work type.
Steps
| Step | Screen |
|---|---|
| 1. Select the area in Data Composer where the field belongs, then select +. For example, to add a field to a work type, select Data Composer > Work Item, then select +. | ![]() |
| 2. The calculated field blade opens. Enter a Name, a Display Name and a Description. You can also choose or create a Category (see Categorisation of Calculated Fields). The field is optional. | ![]() |
Important note on the context of functions
If the Context card displays Work Item (as in the image above), write paths without workitem. at the start. For example, write roles.client.ods.person.lastName, not workitem.roles.client.ods.person.lastName.
A path that starts with workitem. does not produce an error. It returns an empty value, so counts return 0 and comparisons give a wrong answer. For example, count(workitem.roles.witness) returns 0 on a matter that has three witnesses. The examples in this article are written without the prefix.
| 3. Enter your expression. For help, see the Writing expressions and Functions tabs. Use the buttons below to browse the data, check the expression and test it. |
|
4. Select Save or Save & Close. If the work type has child types, the Cascade Changes dialog asks whether to apply the field to the child types too. Select Yes to add it to the child types, or No to add it to this work type only. The same dialog displays when you edit or delete the field. On a work type without child types, the field saves without the dialog. |
Blade and editor buttons
| Button | Where | What it does |
|---|---|---|
| Browse | Ribbon | Opens the Context Browser, which lists the data that you can use. |
| Debug | Ribbon | Opens the debugger (see the Debugging tab). |
| Delete | Ribbon | Deletes the field. Displays on a saved field only. |
| Save, Save & Close | Ribbon | Saves the field. Save & Close also closes the blade. |
| Close | Ribbon | Closes the blade. |
|
|
Editor | Opens the debugger, as the ribbon button does. |
Help
|
Editor | Opens this article. |
|
|
Editor |
Checks that the expression syntax is correct. If it is, the foot of the editor displays "Success!". Errors display at the foot of the window. Validation checks the syntax only: a path that does not exist, or a typo such as ![]() |
|
|
Editor | Switches the expression window between full-screen view and normal view. |
If the editor displays a message about the Expression Engine version, see Expression Engine versions on the Writing expressions tab.
Finding and managing calculated fields
- To find a field in Data Composer, search for its display name. The search does not match the system name.
- To see every calculated field in the system, navigate to Modeller > Rules > Calculated Fields. The list displays each field's graph, name, display name, type, entity type, type path, and whether it is inherited or global.
- To see the calculated fields of one work type, open its Data Composer and select View fields in the ribbon. The Calculated Fields blade lists each field's Name, Display Name, Description, On Type and Type Path.
- On a work type that has a parent type, the ribbon also displays Copy fields from Parent. Select it, select the fields to copy, then select Confirm. Confirm is unavailable until you select a field.
Depending on where you add a field, the Context card of the calculated field blade can display two options:
| Option | Displays when | What it does |
|---|---|---|
| Apply to this specific type of … | The type can hold different kinds of entity. | When selected, adds the field only to that kind of entity, for example a person. |
| Is global for all … types | Fields can be global, for example on document templates. | When selected, makes the field available to every type in that graph. |
Deleting a calculated field does not ask you to confirm. The field is deleted when you select Delete, unless the work type has child types, in which case the Cascade Changes dialog displays first. Before you delete a field, check whether templates or other fields use it.
Adding a Calculated Field to a List
You can add a calculated field to a list by selecting the + button underneath the filter for the list. One use for this is adding calculated values to a list or displaying parent information in a list. For more information, see the article Calculated Lists.
The field is added to the type that the list contains, not only to that list. For example, a field that you add from a list of children is added to every Work Item Base, and the blade displays "This calculated field will be added to all instances of Work Item Base."
When you create a calculated list, for example with the + button on a list such as Participants, the blade displays a Sort By card. To sort the list:
- Select + on the Sort By card.
- Select a field in the Context Browser.
- Choose Ascending or Descending.
To sort by more than one field, add more fields. Without a sort field, the list keeps the order of the list that it is based on.
Categorisation of Calculated Fields
If you have many calculated fields in your system, you can organise them by creating categories and assigning fields to the categories.
Use the Category drop-down to assign a field to a category. To create a category, enter a new name and select Add new category. Data Composer lists each category's fields under their own heading.
The following video shows this in practice:

✏️ Writing expressions
Operators & Keywords
The following is a list of the operators and keywords you can use when creating calculated fields.
Rules for writing expressions
- Put a space on both sides of an operator. Without spaces, a hyphen becomes part of a field name:
reference-1is read as a field calledreference-1. - Enclose text in straight single quotes, e.g.
'hello world'. Curly quotes (‘ ’) cause a syntax error. - Use square brackets only for lists, e.g.
[313081,31002,31003].[title]is read as a list that contains the title. - Function names are not case-sensitive:
format,FormatandFORMATall work. - The arithmetic operators have equal priority and are worked out from left to right, so
2 + 3 * 4returns 20. Use brackets to control the order. See Mathematical Calculations on the Functions tab.
Use the dropdown to filter by category, or type in the search box to narrow results further.
| Categories | Operator | Description |
|---|---|---|
| Arithmetic | + | Add numeric values or concatenate strings e.g. firstname + ' ' + lastname |
| Arithmetic | - | Subtract numeric values. |
| Arithmetic | * | Multiply numeric values. |
| Arithmetic | / | Divide numeric values. |
| Arithmetic | % | Returns the remainder of a division, e.g. 7 % 3 returns 1. Version 2 only. 7 % 0 returns the text "Overflow error". |
| Comparison | = | Equals. |
| Comparison | <> | Not equal to, e.g. roles.client.ods.person.lastName <> 'Fred' |
| Comparison | > | Greater than. |
| Comparison | >= | Greater than or equal to. |
| Comparison | < | Less than. |
| Comparison | <= | Less than or equal to. |
| Lists | in |
Matches one of the values listed, e.g. subtype.id in [313081,31002,31003]. not in matches none of them. With text on both sides, in checks for a substring, e.g. 'abc' in 'xabcx' returns true. Version 2 only. |
| Logic | and | And. |
| Logic | or | Or. |
| Logic | not | Reverses a condition, e.g. not contains(type.path, 'defendant'). |
| Lists | ... | Spreads the items of a list into a new list, e.g. [...roles.witness.select(x => x.ods.name), 'Extra'] returns the witness names followed by Extra. Version 2 only. |
| Values | true | True. |
| Values | false | False. |
| Values | null | Null. |
Examples
Operator |
Example |
|---|---|
= |
Tests whether the work item's sub-type has an ID of 31003. Returns True if a match is made. |
In |
Tests whether the sub-type is any one of the three values. Returns True if a match is made. |
> |
There is more than one Buyer on the property transaction. Returns True if a match is made. |
+ |
Returns the first buyer's name, e.g. "Joe Bloggs". Add the two fields together, with a space in between. |
Using Fields with Special Characters
When a field's query string contains special characters, you must ‘escape’ those characters for the query to be valid. For example, the following query string raises an error:
financialTransactions!q?code=CLIENT;REC;DEBTPRINCIPLE&transactionTypes=invoice&total=true.amount
The error is similar to: Syntax error (line 1, column 36): unexpected `;`.
Escape each semicolon with a backslash:
financialTransactions!q?code=CLIENT\;REC\;DEBTPRINCIPLE&transactionTypes=invoice&total=true.amount
Data Composer Tags in Expressions
When using tags in an expression, you can use the 'local' name of a field.
For example, in a calculated field that you add to the phase of a work type, you can refer to the phase name as either workitem.phase.name or name.
When using data composer tags in expressions, you can move through the data hierarchy:
| Operator / Keyword | Description |
|---|---|
| $root | Takes you to the top of the data. Follow it with workitem. in a work item field, or context. in a document, e.g. $root.workitem.parent.reference. |
| $parent | Moves one step up the field's own data path. Repeat it to move up further. For example, for a field on Work Item > Roles > Claimant, $parent.$parent.reference returns the work item's reference. |
| parent. | The parent work item. Only its basic fields are available, e.g. reference, title, type, phase, and sub-type: parent.reference. |
| ancestors | All the work items above this one. Use a query to choose one and to reach its participants and other data, e.g. ancestors!q?path=matter!1.roles.claimant!1.ods.name. |
$root and $parent return empty values inside a lambda function. To use a value inside a lambda, put it in a variable first:
var today = $root.env.now.utc.value;
roles.claimant.select(x => x.ods.name + ' ' + dateDiff(x.ods.person.dateOfBirth, today, 'y'))
Comments
Start a comment with /* and end it with */. The editor displays comments in green text. A comment can be on one line or span several lines. Comments are available in version 2 only.

For example, this comment explains the expression that follows it:
/* Add 10 days to today */
format(dateAdd('d', 10, $root.env.now.utc.value), 'dd MMM yyyy')
This comment stops part of an expression from running while you test:
/*
Work in progress:
dateAdd('y', 1, $root.env.now.utc.value)
*/
reference
Expression Engine versions
Calculated fields run on a versioned expression engine. When Clio Operate makes a major change to the engine, it releases a new version of it and keeps the earlier versions available. Each calculated field stores the version it was written against, so it is always evaluated against the grammar it was built for. New fields use the latest version. The Version field displays above the expression editor only when a field uses an older version.
If a field is on an older version, the calculated field blade displays the message "The latest expression engine version is not being used. Upgrade by changing the version in the dropdown below."

This message is informational. It does not mean the field is broken, and it does not mean the field will stop working. The only practical difference is that a field left on an older version cannot use what later versions add.
Compare version 1 and version 2
New fields use version 2. The table lists what each version supports.
| Feature | Version 1 | Version 2 |
|---|---|---|
Arithmetic (+ - * /), comparisons, and, or
|
Yes | Yes |
Functions, such as format(…) and if(condition, a, b)
|
Yes | Yes |
if … then … else |
No. Use if(condition, a, b). |
Yes |
The % operator |
No | Yes |
not, in and not in
|
No | Yes |
Lists in square brackets, e.g. [1, 2, 3]
|
No | Yes |
Spread (...) |
No | Yes |
Lambda functions (=>), e.g. select, where, any
|
No | Yes |
var and ;
|
No | Yes |
Comments (/* … */) |
No | Yes |
| Reserved words |
and, or, true, false, null
|
Also if, then, else, not, in, var
|
Upgrading a field
To upgrade a field, select a newer version in the Version field, then select Save.
Upgrading recompiles the expression under the newer grammar. This is low risk for the majority of expressions, but check the following before you save:
- Later versions reserve additional keywords. Version 1 reserves
and,or,true,falseandnull. Version 2 also reservesif,then,else,not,inandvar. An expression that references a field named after a reserved keyword needs a small change before it validates. - Validate the expression after changing the version. Any errors display at the foot of the editor.
- Run the field against a real work item in the debugger and confirm the result matches the result from the previous version.
Upgrading multiple fields
There is currently no bulk upgrade option. Upgrade each calculated field individually from its expression editor.
🔣 Functions
Common Functions
The following is a list of commonly used functions that you can use to build up your expressions within calculated fields.
In the table below, the function parameter my_field refers to the field against which you run the function. A comma separates any further parameters, and function parameters are enclosed in brackets.
You can find a list of Culture Codes here: Supported Culture Codes.
To find a function, type in the Search the whole page box above the tabs, or use the dropdown above the table to show one category. To copy a link to a function, hover over its row and select the link icon in the first cell.
To list every function while you write, press Ctrl+Space in the expression editor:

Use the dropdown to filter by category, or type in the search box to narrow results further.
| Categories | Function | Description and examples |
|---|---|---|
| Text | toUpper(my_field) |
Changes the case to uppercase. Example
Converts Smith to SMITH.
|
| Text | toLower(my_field) |
Changes the case to lowercase. Example
Converts Smith to smith.
|
| Text | toTitleCase(my_field) |
Changes to title case (first letter upper case). Example
Converts smith to Smith.
Note: this function only works for text in lowercase. It will not convert all uppercase text to title case. To do this, combine the two functions together as follows:
|
| Text | isNullOrEmpty(my_field) |
Returns true if the field's value is null or an empty string. Example
Returns true if the work item's File Review Key Date has not been set, else false. Important: This function only applies to Strings. To use this function with a date or a number, you must convert it to a string with For example, this expression returns true if a key date is more than 7 years in the past. If the key date is not set, it returns false.
|
| Text | startsWith(my_field, 'string to check') |
Returns true if the string starts with the characters provided. Add an optional third argument to change how the text is compared, e.g. Example
Returns true if the work type's system name starts with matter-dispute. |
| Text | startsWithIgnoreCase(my_field, 'string to check') |
Returns true if the string starts with the characters provided, regardless of case.
|
| Text | endsWith(my_field, 'string to check') |
Returns true if the string ends with the characters provided. Add an optional third argument to change how the text is compared, e.g. Example
Returns true if the work type's system name ends with dispute. |
| Text | endsWithIgnoreCase(my_field, 'string to check') |
Returns true if the string ends with the characters provided, regardless of case.
|
| Text | contains(my_field, 'string to check') |
Returns true if the field contains the string specified. Add an optional third argument to change how the text is compared, e.g. Example
Returns true if the work type's path, for example matter-dispute-defendant-pi-medical-negligence contains the word defendant.
|
| Text | containsIgnoreCase(my_field, 'string to check') |
Returns true if the field contains the string specified, regardless of case.
|
| Text |
Returns all the text to the left (or right) of a string, for the number of characters specified. Example
Converts John to J.
Converts John Smith to SMITH J. This kind of function can be used to build up names in the format required by specific documents. It is frequently used in ODS calculated fields to create dedicated court or contract participant names.
|
|
| Text | length(string) |
Returns the number of characters in a string. Example
If the work item reference is D.MD.23.0012, the length function returns 12.
|
| Text | substring(my_field,startIndex,length) |
Returns a substring that starts at the specified character position (startIndex) and continues for the number of characters specified (length). The index is 0 based, so the first character has the index 0. Example
This extracts the third and fourth characters. e.g. D.MD.23.0012 becomes MD. The length is optional. Without it, If the start index plus the length runs past the end of the string,
To return a substring where you do not know the start index or the length of the value you need to retrieve, for example if you need everything after the . in the following: you can use this as an example:
This would return: 6666232
|
| Text | indexOf(string,pattern,comparisonType) |
Returns the zero-based index of the first occurrence of the specified substring in the string. The optional Example
Where the work item reference is D.MD.23.0012 Returns 2.
|
| Text | lastIndexOf(string,pattern,comparisonType) |
Returns the zero-based index of the last occurrence of the specified substring in the string. The optional Example
Where the work item reference is D.MD.23.0012 Returns 3.
|
| Text | replace(my_field, oldValue, newValue) |
Returns a new string in which all occurrences of a value are replaced with a new value. Example
This example replaces the international country code from the claimants telephone number with 0. You can also add the field to the ODS, which makes it available to every entity and participant. For example, on the root of
The field is then available for the primary direct-dial number of every ODS entry.
|
| Text | split |
Splits a string based on a specified delimiter into an array of sub-strings. The delimiter can also be a list of delimiters. Add
Example
Returns
You can use the
Returns
|
| Text | isRegexMatch(my_field, pattern) |
Returns true if the text matches a regular expression. Example
|
| Text | regexReplace(my_field, pattern, newValue) |
Replaces each match of a regular expression with a new value. Example
|
| Text | toString(my_field) |
Converts a value to text. Example
|
| Text | equals(value1, value2, comparisonType) |
Returns true if two values are equal. For text, the optional Example
|
| Text | Text comparison options |
These functions take an optional last argument that sets how text is compared:
Any other value is ignored, and the comparison is case-sensitive. Example
|
| Numbers | round(my_field) |
Rounds a decimal value to the nearest whole number. A value that ends in .5 rounds to the nearest even number, so
Example For example, a dateDiff function returns the total number of days between two key dates, as follows: e.g. 13.59069479188 days Using the round function:
The result would be 14 days.
|
| Numbers | floor(my_field) |
Rounds a value down to the nearest whole number. Example A dateDiff function may return 13.59069479188 days. Using the floor function:
Would return 13 days.
|
| Numbers | ceil(my_field) |
Rounds a value up to the nearest whole number. Example A dateDiff function may return 13.59069479188 days. Using the ceil function:
Would return 14 days.
|
| Numbers | abs, sign, power, min, max |
Number functions:
These functions return 0 for a value that is not a number.
|
| Numbers | numberToWords(my_field,case) |
Returns a number expressed in words. The words include "and", e.g. A negative number starts with "minus", e.g. case can be:
Write the case value in lower case: Example
Returns: "Two".
no_of_witness is a calculated field that counts the witnesses. Returns: "three". The case is lower by default, so you do not need to pass it.
Returns: "SEVENTEEN" Calculates the age in years of the first occupier participant living in property for sale. With 'd', the function returns the age in days.
|
| Numbers | currencyAmountToWords(my_field, currencyCode,case) |
Returns a currency expressed in words. currencyCode can be:
Any other code, e.g. case works as for numberToWords: Example
Converts the amount of the most recent offer received (£15,500.01) into British Pounds and returns the value as text, in capital letters. "FIFTEEN THOUSAND FIVE HUNDRED POUNDS AND ONE PENCE"
Converts the amount input into a Form Builder questionnaire on a prepare document blade into US Dollars, using title case. "Twelve Dollars and Fifty-Five Cents"
|
| Numbers |
|
The arithmetic operators
An empty (null) value changes the result: Dividing by zero returns text, not a number: Example
Takes the amount input by the user into a prepare document questionnaire field and multiplies it by 52. It is then formatted to return the value in words, in US format: If the weekly amount is 25.85: One Thousand Three Hundred and Forty-Four Dollars and Twenty Cents |
| Dates and time zones | now |
Returns today's date. Example
Returns: 2023-09-25T13:43:33.7516307Z The date and time are returned in UTC, in ISO format. To format the date, see format. To check whether a key date is in the future:
Compare the key date directly. Key dates are already dates, and
A time zone name that is not recognised returns the time in UTC, without an error.
|
| Dates and time zones | dateDiff(startDate,endDate,datePart) |
Returns the difference between two dates, in the unit set by datePart:
Any other value, including 'h' and 'M', returns the difference in days without an error. Example
Returns the age of the 1st claimant in years, by comparing the number of years between their birth date and today's date.
Calculates the number of days from the date of the initial instruction to a property exchange date. Each date path must end with
|
| Dates and time zones | dateAdd(datePart,number,date) |
Adds a number to a date, in the unit set by datePart:
Commonly used with the format function to format the results. Example
Adds 10 days to the incident date. Returns: 2023-08-29T09:36:43.2100000+00:00
Subtracts 1 year from the date of an incident. Returns: 2023-08-01T08:00:00.0000000+00:00 You can also put the date first and the unit last, e.g. To add a time span, use Any other unit, such as
|
| Dates and time zones | parsedate(my_field, 'culturecode') |
Converts the string representation of a date and time to a 'DateTime' equivalent, using the mandatory culture code. Commonly used to convert date fields held on Form Builder forms, which Clio Operate stores as text in the format that the form field uses, e.g. 12/09/2023. In documents, these dates appear as stored, so use Example
Converts a Form Builder date from a string to a date, using the British culture code. In these examples, the stored value is 12/09/2023. Returns: 2023-09-12T00:00:00.0000000+00:00 The same field, but using the American culture code:
Returns: 2023-12-09T00:00:00.0000000+00:00 Note the days/months are reversed. The format function can be used in conjunction with parseDate:
Returns: 12 Sep 2023 |
| Dates and time zones | format(myfield,format) |
Formats a value using the specified format, and an optional culture code. The default culture is en-GB. Typically used with dates and numbers.
Date and time formats The examples are for 1 March 2026 at 09:37.
Use these letters together, as in Number formats Add a number to set the decimal places, e.g.
Examples
You can combine
|
| Dates and time zones | toLocalDateTime, toUtcDateTime, getTimeZone |
Time zone functions. Write the time zone as an IANA time zone name, such as Europe/London.
If the time zone is not recognised, To read one detail from
|
| Lists | count(my_list) |
Counts the number of items in a list. Example
Returns the number of witness participants assigned to the work item. E.g., returns: "3"
Counts the number of proceedings created (whether currently open or closed) on a matter. Add a predicate to count only the items that match it, e.g. Note:
|
| Lists | elementAt(list, index) |
Looks up the specified index number in a list of values. For example, find the 3rd item in the list. As this function is 0 based, the first item has an index of 0, the second item an index of 1, the third item an index of 2, etc. Example
Returns the name of the 3rd witness in the list. For participants, select the value first:
|
| Lists | pluck |
Returns a new list constructed from the specified property of each element in the list. Example A participant may have more than one role on a work item (e.g. both client and claimant). A document recipient's roles are therefore returned as a list. pluck extracts one property from each role in that list. For example, on a document template that has a To: Recipient role, create a document calculated field on Document Recipient > Context Participant. Use the expression:
This would return the system names of the role of the selected document recipient: e.g. "client,claimant" This can be combined with the If Then Else statement. For example, when a letter can go to one of several participant roles, you can change the subject line to suit the recipient:
In this example, when writing to either the client or any of their representatives: if the recipient is the client, return the words "Your claim", else return "Your client's claim". Two single quotes ('') put an apostrophe in a string. Note:
|
| Logic and variables | If Then Else |
If statement that will check a condition, and then return specified values for true and false. Example
Checks if there are one or more witnesses, if so, it returns the text Has witnesses. If there are none, it returns Does not have witnesses.
If the id of work item subtype is 313081, then return true, else return false. Note: this can simply be abbreviated to:
as the default return values are true or false. You can also write an If as a function:
Nested For example:
|
| Logic and variables | coalesce(my_field1,my_field2,my_field3) |
Evaluates the arguments in order and returns the value of the first expression that doesn't evaluate to null. Example
Where one or more participant roles could be assigned to a work item, then cycle through each of the participant names (in order specified) and return the first name found.
|
| Logic and variables | var |
Declares a local variable and assigns a value to it. End each declaration with the Example
This expression creates two local variables for two sub totals. A third variable adds the two sub totals together. The expression then formats the total as a currency value.
If any field value in the calculation is null, the sub totals and the total can be null or wrong (see Mathematical Calculations). To replace a null value with 0, use
|
| Other | newGuid(), getHash() |
Call
|
📋 Lists and lambdas
Advanced Calculated Fields
Lambda functions work on lists, such as the participants in a role. Each one takes a short function, written x => …, and applies it to every item: select changes each item, and where keeps the items that match. The result is often joined into one value, for example a comma-separated list of names for an email or a document.
For example, you can select the occupiers of a sale property who are over 18 and join their names into one string, or list all the payments made between two dates.
Things to know
- Lambda functions work in version 2 only. See Compare version 1 and version 2 on the Writing expressions tab.
-
filteris an alias ofwhere: they do the same thing. - A lambda can also take the position of each item in the list, starting at 0, e.g.
roles.witness.select((x, i) => i + ': ' + x.ods.name)returns 0: Nathan Witness, 1: Wendy Witness, 2: Andrew Witness. - You can split a long expression over several lines, with one function per line. These two expressions are the same:
roles.claimant.select(x => x.ods.name)
roles.claimant
.select(x => x.ods.name)
Use the dropdown to filter by category, or type in the search box to narrow results further.
| Categories | Function | Description and examples |
|---|---|---|
| Transform | select |
Projects each element of a list into a new form. Parameter: Selector = a transform function to apply to each element to return all the results as a single value.
Returns: Brian Edwards,Whit Stillman,John McClaim,James Sample
Iterate through each of the claimants for the work item. x represents each individual entry returned by roles.claimant. Accordingly, x (roles.claimant ) is the parent root and child tags can be used to extract specific data. In this example, ods.name is used to obtain the name of each claimant. Select then returns all the results and projects into its new form (a list of claimants presented in a comma-separated format). |
| Transform | selectMany |
Projects each element of a sequence to a list and flattens the resulting sequences into one sequence. Parameter: Selector = a transform function to apply to each element to return all the results as a single value.
This expression lists the email addresses of every third party on a work item. Each third party has its own list of email addresses.
This is particularly useful for financial queries:
This adds up the invoice's financial transactions that have the segment code ABC123. After a filter, include every property that you need in the filter's condition. Here, |
| Transform | map |
An alias of select.
|
| Transform | reduce / aggregate |
Combines the items of a list into one value. The lambda takes the running result and the current item. An optional second argument sets the starting value. aggregate is an alias of reduce.
|
| Filter | where |
Allows you to filter a list/array based on some predicate. See the
Returns the names of all the witnesses whose names begin with ‘Bob’.
|
| Filter | filter |
Filters a list of values based on a predicate. Parameter: Predicate = a function to test each element for a particular condition.
Returns: Whit Stillman,John McClaim
Iterate through each of the claimants for the work item and filter by the legal capacity of each claimant. I.e. x.legalCapacity.legalCapacity = true Select returns the name of the each relevant participant and transforms the filtered results into a list of claimants presented in a comma-separated format.
|
| Filter | except |
Excludes one or more entries from a list, based on a predicate. Parameter: Predicate = a list of one or more values to exclude.
In this example, the calculated field is used on a document template that presents a list of all Appointment work items drawn from the parent matter. The user selects the relevant Appointment, and the names of each Attendee are returned. The script excludes the Client's name from the list, as this is not required. The path of this calculated field is Document / Activity / Related / First Appointment. Note: the square brackets are required because except expects a list on the right-hand side. Where a role is configured to hold a single participant (as with Client here), To exclude more than one role, list them inside the brackets:
If the role is configured to "Allow Multiple", the field already returns a list, so brackets are not needed:
|
| Filter | distinct |
Removes duplicate items from a list. An optional selector keeps the first item for each value of the selector.
|
| Filter | skip / take |
skip leaves out the first number of items. take returns only the first number of items.
Note: on a role, select the value first. |
| Filter | skipWhile / takeWhile |
skipWhile leaves out items until the predicate is false. takeWhile returns items until the predicate is false.
|
| Filter | first / last |
Returns the first or last item in a list. An optional predicate returns the first or last item that matches it. An empty list returns null.
Note: on a role, select the value first. |
| Test | any |
Returns a true result where any result in the list matches a value. Otherwise, it returns false.
Returns a true result if ANY of the entries selected by the user return a value of Note: This function is ideal when the user can select several entries from an option set, and you need to know whether they selected one specific entry. For example, an option set asks the user to select all the housing statuses that the client has held in the past 3 years. This expression checks whether the user selected HomeOwner, even if they also selected other statuses, and returns the matching text:
In a second example, an expression checks whether the first half of a property's postcode matches a code in a list of restricted codes. For example, M33 3AB matches on ‘M33’.
|
| Test | all |
Returns a true result where all results in the list match a value. Otherwise returns false.
Returns a true if ALL of the witness' names start with 'Bob'. Note: use
Combining a couple of the functions above: getting a list of child properties using
|
| Test | some / every |
Aliases of any and all.
|
| Combine | join |
Concatenates the elements of a list, using the specified delimiter between each element. Parameter: Delimiter = String e.g. join ('|')
Returns: Brian Edwards, Whit Stillman, John McClaim, James Sample
Remember: by default, the select function will return multiple values in a transformed list/array. join allows each value in the list to be replaced by a different separator – in this example, a comma followed by a space. Alternatively, .join('|') - returns a pipe-separated list. .join('\n') - puts each entry on a new line in a generated Word document or HTML email. The debugger displays |
| Combine | union |
Joins multiple lists together Source1 – first list Source2 - second list etc
Results: Andrew Barrister, Larry Friend, Simon Solicitor
Returns a list of all the participants in any of the three roles that act on behalf of the claimant (counsel, solicitor, litigation friend). Note that other functions, such as Join, orderBy, etc., can be applied to the result. Every role in the expression must exist on the work type: a role that does not exist makes the whole result null. unionAll works the same way but keeps duplicates. An empty role does not affect a union. The result is null only if every list is empty. If a role holds one participant, such as a litigation friend, put its value in square brackets. Otherwise, the result has an empty item, which leaves a trailing comma after join. Apply filter to each list before you combine it, not to the combined result.
This example lists the claimants and the litigation friend. The square brackets turn the litigation friend's single name into a list. |
| Combine | intersect |
Returns the items that are in both lists. Text is compared case-sensitively.
|
| Text | replace |
Replace each instance of a value with another value. Parameters: oldValue = string newValue = string
Returns: Brian Edwards and Whit Stillman and John McClaim and James Sample
+44 replace with 0 replace(roles.claimant!1.ods.contact.direct-line!1.value,'+44 ','0') |
| Text | replaceLast |
Replace the last instance of a value with another value. An optional fourth argument changes how the text is compared, e.g. Parameters: oldValue = string newValue = string
Returns: Brian Edwards, Whit Stillman, John McClaim and James Sample
As above, where join produces a list of comma-separated values, the final comma is replaced with the word "and". Include the spaces that you need in the new value: This is typically used in letters and emails to return a list of participants. |
| Sort | orderBy |
Sorts the elements of a list in ascending order.
Returns: Brian Edwards, James Sample, John McClaim, Whit Stillman
The list of participant names is returned in alphabetical order.
You can also pass in a predicate to order by different properties before returning a set of results. For example, using this data (shown as the debugger displays it):
Script example 1:
This script:
Script example 2:
This script:
|
| Sort | orderByDescending |
Sorts the elements of a list in descending order.
Results: Whit Stillman, John McClaim, James Sample, Brian Edwards
The list of participant names is returned in reverse alphabetical order. |
| Calculate | sum |
Returns the sum of a list of numeric values.
This expression performs a sum of all the 'General' Invoice amounts on the work item. The total includes draft invoices. |
| Calculate | average |
Returns the average of a list of numeric values.
This returns the average invoice amount. The selector is optional for Note: an empty list, or a list with no numbers, returns the text "Error evaluating tag: Sequence contains no elements". Checking the list with
This returns the average invoice amount, or null when there are no invoices. |
| Calculate | min |
Returns the minimum value in a list of values.
This returns the smallest invoice total. Note: an empty list returns a very large number, 7.922816251426434e+28. To return null for an empty list, sort the list and take the first item instead: |
| Calculate | max |
Returns the maximum value in a list of values.
This returns the largest invoice total. Note: |
Roles that hold one participant
Some roles, such as Client and Claimant Litigation Friend, hold one participant. For these roles, the path returns one participant instead of a list: roles.client.ods.name and roles.client!1.ods.name return the client's name, but count(roles.client) returns 0 and roles.client.select(…) returns an empty item.
To use one of these roles in a list function, put its value in square brackets, e.g. [roles.client.ods.name].
📄 Documents
Display Rules with Lambda Functions
Lambda functions can also be used in Display Rules in the ShareDo Word Plugin. The function returns a true or false result, which then shows or hides a Tag, Section or Content Block in the generated document.
Scenario
A Prepare Document template presents the user with an Option Set containing two entries: Tenancy Documents and Title Documents.

Display Rules are required to handle each combination of selection, so that the relevant Sections appear in or are hidden from the generated document.
In this example (option set value IDs are different in each environment, so check the IDs in your option set):
- The Option Set ID for Tenancy Documents is 500001914.
- The Option Set ID for Title Documents is 500001915.
Each of these display rules returns true when the user makes that selection:
| The user selected | Display rule |
|---|---|
| Tenancy Documents only | |
| Title Documents only | |
| Both options | |
| Exactly one option | |

Testing display rules
The Word plugin checks the syntax of a display rule, not its paths. If a path is wrong, the rule returns false and the content is hidden without an error. Clio recommends that you test every display rule by generating a document against a real work item. If a rule cannot be evaluated, the generated document displays an error in red, e.g. "Error evaluating the display rule 'Recipient is client' for this control."
Do not use pluck in a display rule. To check a list of values, use any, or select with contains:
document.recipient.contextRoles.any(x => x.roleType.systemName = 'client')
contains(document.recipient.contextRoles.select(x => x.roleType.systemName), 'client')
Calculated Fields in Documents
A document template reads data through three starting points:
| Starts with | What it reads | Example |
|---|---|---|
context. |
The work item that the document is for, including its calculated fields. A calculated field that you add to Work Item is available as context. followed by the field name. |
context.reference |
document. |
The document itself, including the questionnaire answers and the recipient. The recipient's roles on the work item are at document.recipient.contextRoles. |
document.questionnaire.weekly_pay_amount.valuedocument.recipient.ods.name
|
env. |
The environment. | env.now.utc.value |
Documents do not have a workitem. path: use context. instead. Form Builder dates appear in documents as stored, e.g. 12/09/2023.
Litigation Parties
Courts commonly require that all parties in a particular Role (e.g. claimant, defendant) are presented in a list comprising their name, their "ordinal" (e.g. First Claimant, Second Claimant, Third Claimant, etc.) and their address.
For example, a list of all claimants on a Proceeding:
(FIRST) Peter Thompson, Lock Keepers Cottage, Basin Road, Worcester, Worcestershire, WR5 3DA; (SECOND) William Smith, 2 Oxbridge Close, Sale, Greater Manchester, M33 5XJ and (THIRD) Fred Jones, 1 The High Street, Hale Barns, Altrincham, Greater Manchester, WA15 0WU.
Note the final 'and' between the second and third claimants' details. The replaceLast step in the expression below adds it.
If only one participant holds a role, courts often ask that their ordinal is not presented. For example, if more than one defendant is party to proceedings, use "FIRST Defendant", "SECOND Defendant", and so on. Otherwise, present "Defendant".
All of the above can be achieved using the following expression:
if count(roles.claimant) > 1 then
roles.claimant.select(x =>
'(' + x.roleOrder.ordinal.toUpper() + ') ' +
x.ods.name + ', ' +
x.locations.5002500.formattedCsv)
.join('; ')
.replaceLast('; ', ' and ')
else
roles.claimant!1.ods.name + ', ' +
roles.claimant!1.locations.5002500.formattedCsv
roleOrder.ordinal returns First, Second, Third, and so on. locations.5002500 is the participant's correspondence address. If a participant has no correspondence address, the text keeps the comma after the name.
The following expression will return all claimants and their roles on a new line.
if count(roles.claimant) > 1 then
roles.claimant.select(x =>
x.roleOrder.ordinal.toUpper() + ' Claimant: ' + x.ods.name)
.join('\n')
else
'Claimant: ' + roles.claimant!1.ods.name + ', ' + roles.claimant!1.locations.5002500.formattedCsv
For example:
FIRST Claimant: Peter Thompson
SECOND Claimant: William Smith
THIRD Claimant: Fred Jones
In a generated document, the lines are line breaks within one paragraph, not separate paragraphs.
🧩 Script functions
User-Defined Script Functions
User-defined script functions are functions which can be written to perform a specific task. Expressions can reference these functions, pass values to them, and receive the resulting data. Storing these functions centrally and calling them only when required ensures uniformity/standardisation and saves rewriting the same script into every expression where a specific task is required.
For example, a function can be scripted to convert a date into a specific format. Rather than write this code into every expression that requires a date to be formatted, a single user-defined function can be called, and the date passed to the function for formatting.
The Script Functions editor is available via Modeller > Rules > Script Functions.
You need either the core.modeller or the core.adminAccess system permission to manage script functions.

Script Function Examples
This example creates a function that replaces the +44 prefix of a UK telephone number with 0.
| Step | Screen |
|---|---|
| 1. Select New to create a script function. The script function editor opens. | ![]() |
2. In the Field section, enter a name and a description for the function. The name cannot be the same as a built-in function, such as sign: the editor displays "sign is a reserved identifier and cannot be used". |
|
| 3. Select + to add a parameter. Parameters set which values a calculated field can pass to the function, for example a date to format. | |
| 4. Enter a Name for the parameter, for example ParticipantNames or IncidentDate. This example uses telephoneNo. Leave Default Value and Optional as they are: the next example uses them. | ![]() |
|
5. Write the expression. The editor works like the calculated field editor, except that the parameter name holds the value that a calculated field passes in. This example uses:
If the telephone number in telephoneNo contains +44 followed by a space, the prefix is replaced with 0. |
|
| 6. Save the function. It is added to the list of script functions. |
Using the new function
To use the function in a calculated field, call the function and pass the field name to be formatted. For example:
RemoveUKCountryCode(roles.claimant!1.ods.contact.direct-line!q?primary=true.value)
When run, the claimant's direct-dial telephone number will have its prefix of '+44 ' replaced with a '0'. If you call a function without a required parameter, validation displays an error, e.g. "requires 1 argument(s)".
A more complex example
This example adds two parameters to a function, and uses the Default Value field and the Optional toggle.
This function removes all country codes, not just the UK's.
As before, create a new function called RemoveCountryCode, with these parameters:
| Parameter | Optional | Default value | Purpose |
|---|---|---|---|
telephoneNo |
Off, so the parameter is mandatory | None | The telephone number. |
prefix |
On | '+44 ' |
The country code to replace. If the call does not pass a prefix, the function uses the default value. |
The expression is as follows:
replace(telephoneNo, prefix, '0')
It works like this: take the telephone number and look for the value passed in the prefix parameter. If this is not passed, use the default '+44 '. Replace the prefix value with a 0. For example, RemoveCountryCode(roles.claimant!2.ods.contact.direct-line!q?primary=true.value, '+61 ') turns +61 400 123 456 into 0400 123 456.
The result is a generic function. Pass any international country code as the second parameter, or leave it out for a UK number.
In a calculated field, call the function as follows:
RemoveCountryCode(roles.claimant!1.ods.contact.direct-line!q?primary=true.value)
Formatting a date in German
This function converts a date to German display format, for example, 13. März 2026.
Create a new function called ConvertGermanDateFormat with a single mandatory parameter, thedate.
Add the following expression:
format(thedate, 'dd. MMMM yyyy', 'de-DE')
The German culture code de-DE makes format use German month names, so the expression returns the day, the German month name, and the year.
To use the function in a calculated field, call it and pass the field to be formatted:
ConvertGermanDateFormat(oralHearingDate)
If oralHearingDate holds 13 March 2026, the function returns 13. März 2026.
Deleting Script Functions
You cannot delete a function while expressions use it. To delete a function, open it and select Delete in the ribbon. The Find Usages panel lists where the function is used.

Select the Manage icon (a cog) next to a usage to open it, and remove the function from that expression. Then select Refresh: the panel displays "No usages found."
Delete stays unavailable until no usages remain. Select Delete and confirm. The delete is permanent and cannot be undone.
🐞 Debugging
Debugging Expressions
Select either the Bug icon or the Debug button to open the Debugger. The debugger runs the expression without saving the field.
| Button | What it does |
|---|---|
| Run | Runs the expression against the selected work item, or against data that you enter. See Testing Expressions. |
| Browse |
Opens the Context Browser for the selected work item. To copy a tag name, navigate to the tag and select the copy icon, then paste it into the expression editor.
|
| Functions | Opens the Script Functions list, which shows the script functions that you can call. See the Script functions tab. |
| Save | Closes the debugger and passes the expression, with any changes that you made, back to the calculated field blade. Save the field to keep the changes. |
| Cancel | Closes the debugger without passing any changes back. |
To choose how to find a work item, select the arrow next to the search box. The debugger does not check that the work item matches the field's work type, so choose a work item of the right type.
Choosing a work item
| Option | How to use it |
|---|---|
| Quick Search |
In the search box at the top left, enter a keyword from the work item, e.g. part of the client's name, the matter reference or a participant name. Select the work item in the list of matches.
|
| Advanced Search | Select the Select… box to open the advanced search. You can search by reference, title, type, dates, owner or participant. Select the work item, then select Confirm. |
| Manual Entry | Enter the unique ID of the work item. |
Testing Expressions
| Step | Screen |
|---|---|
| 1. Choose a work item (see Choosing a work item), then select Run. The debugger runs the expression against that work item. | |
| 2. Check the left-hand console. The console lists any data referenced by the expression. | ![]() |
| 3. Check the green panel at the foot of the form. The panel displays the expression results. |
For example, if an expression formats a key date, the console displays the date as it is stored:

The results panel displays the result of the expression, which is the formatted date:
![]()
You can also test an expression against data that you enter yourself. Without a work item, the debugger uses the JSON in the left-hand console. With entered data, the ! index (e.g. !1) does not work: use .select(…).elementAt(0) instead.


Help






