Introduction to DREL
This topic describes what Data Reference Expression Language (DREL Data Reference Expression Language (DREL) is used to get form data and metadata and add it to a string, such as dates, usernames, or answers to questions in forms.) is, and how to use it correctly to reference information from dispatched or submitted records.
Available on all tiers:
Contents
What is DREL?
Data Reference Expression Language (DREL) is a TrueContext proprietary language used to reference information about Form Submissions. With DREL, you can build expressions that include form metadata and question answers.
You can use DREL to
- customize the name of form submissions in the mobile app and in the Web Portal
- customize the name of folders and document files in data destinations such as cloud services or emails
- include variable content in emails for customers
- set up filtering rules for data destinations, and
- map data and metadata to records within data destinations such as ServiceMax or Salesforce.
How to use DREL
DREL expressions use a combination of references, properties, and static text. DREL expressions can include special characters like spaces, hyphens, symbols, and punctuation. The following image shows an example of an expression using DREL.
-
References are variables that define the information in the expression. They always have a “%” symbol followed by a letter. Some references have a default property.
Example: %u references the last user who submitted a form. This information might be the User ID, Username, or Email, depending on the property. %u without a property returns the user’s Display Name (first and last name and username).
-
Properties specify the information to return for the reference. Place them in brackets [ ] after a reference when you want the system to return a property other than the default, or when the reference doesn't have a default property. Some references can include more than one property.
Example: [name] specifies that the user information returned is the user's first and last name, as configured in their user profile. In the example, %u[name] returns John Doe.
-
Static text provides additional information. The system returns static text as is.
Example: Form Submitted by adds context to the expression and is returned as a text string in the example.
Info:You can test your DREL expression on data from a previous form submission or dispatch.
You can use any number of references to create an expression. The following image shows an expression that includes the Form Submission Properties reference (%r), the User reference (%u), and the Date reference (%d), along with some static text.
Info:The topic DREL Complete Reference List provides a full list of references and properties.
Escape special characters and line breaks
Documents
When you use DREL expressions in text documents such as JSON or XML, remember to add the escape property at the end of the expression. Use the following syntax: [#escapedocumentFormat]
To escape the data referenced by all DREL expressions in a document, include an expression with the following syntax at the beginning of the document: #c[escapeDocumentFormat]
where DocumentFormat
is either Json
, Xml
, Html
, Csv
, or Url
.
To override the global escape, include the following property as part of a DREL expression: [#escapeNone]
When you use the escape property or the global escape expression, the system displays special characters and line breaks in the document format you specify.
Info:The topic Escape Special Characters and Line Breaks for Template-driven Text Documents includes greater detail and more examples of how to use the DREL escape property.
Data Destinations
Data Destination A Data Destination specifies where to send data from a submitted form. You can use Data Destinations to automate data sharing and storage, routing data to a specific service (such as email or cloud storage) in several different formats. filters use regular expressions (regex) to match values. If values returned by a DREL expression include reserved regex characters, you must escape those characters using a backslash (
\
).
The following example shows how to escape special characters for URL and workflow status The workflow status describes how a record moves through your company’s workflow. All statuses include a workflow state, and some also contain the data flow state or completion result. values.
This example shows a regular expression that allows for variations in the workflow status. The regular expression ^Completed(\s+\([^)]+\))?$
matches on Completed
and Completed (any_value)
, such as Completed (Approved)
.
Info:The topic Apply Filtering to Data Destinations explains how to set up filters in more detail.