DSL Examples

View as Markdown

Overview

In Moveworks’ real-world scenarios, DSL examples are integral to streamlining processes within the Moveworks platform. These DSL examples are designed to help you write rules quicker and ultimately improve your user experience and productivity.

Examples

Block a list of forms from being fillable

If, for some reason, you do not want to render a list of forms from being fillable in chat, you can use the Override fillable forms to deflect to ITSM control under Forms > Skill Settings and supplying a list of forms as shown below.

NOT (form_source_id.$LOWERCASE() IN ["d9d720821b3f6c507e8342a2cd4bcbe3".$LOWERCASE(), "489572f3dbf3d70017f73caf9d961920".$LOWERCASE(), "268bdb971bffe010b124cbf2604bcbf1".$LOWERCASE()])

In this case, we are identifying the list of ServiceNow forms (i.e. catalog items or record producers) by their ServiceNow sys_id.


Access a field from Active Directory

When setting up user identity for Active Directory, you’ll notice that fields are not straightforward field: value. The fields will return as a list element [], so you need to use index accessors where 0 is the first element in the list.

Let’s say we want to retrieve the userPrincipalName of the user.

Given Payload Response

1{
2 "id": ["123456"],
3 "userPrincipalName": ["jdoe@example.com"],
4 "displayName": ["John Doe"],
5 "mail": ["jdoe@example.com"],
6 "telephoneNumber": ["+1 234 567 890"],
7 "mobile": ["+1 234 567 891"],
8 "department": ["Information Technology"],
9 "title": ["Senior Developer"],
10 "physicalDeliveryOfficeName": ["HQ - Office 101"],
11 "memberOf": [
12 "CN=Developers,OU=Groups,DC=example,DC=com",
13 "CN=ProjectX,OU=Groups,DC=example,DC=com",
14 "CN=IT,OU=Groups,DC=example,DC=com"
15 ],
16 "accountStatus": ["Active"],
17 "lastLogonTimestamp": ["2023-03-23T08:50:00Z"],
18 "passwordLastSet": ["2023-01-15T09:33:00Z"],
19 "thumbnailPhoto": ["https://example.com/photos/jdoe.jpg"]
20}

To access the userPrincipalName field

1userPrincipalName[0]

Expected Result

1"jdoe@example.com"

Make all elements in a list lowercase

We usually create whitelists for users that want to test a certain skill or sometimes remove access to a list of people. We would want to evaluate all users in lowercase since sometimes emails or other attributes may contain capital letters. A way to lowercase an element is by using the .$LOWERCASE() formatter but it’s not scalable if you have a list of hundreds of users. Here’s how you can do it better.

Given

1emails = ["HeLlo", "WoRld"]

To lowercase all elements

1emails.$MAP(email => email.$LOWERCASE())
2
3# or
4
5["HeLlo", "WoRld"].$MAP(email => email.$LOWERCASE())

Expected Result

1["hello", "world"]

Evaluate a string with multiple elements

We want to evaluate a ticket description with multiple STARTS_WITH, but you do not want to write multiple OR operators in your rule that could make it bulky and hard to read. We can leverage the ANY stream operator to match our ticket with a list of strings or elements.

You can also leverage the ALL operator in case you want AND conditions.

Given

1list_of_prefixes = ["Mr.", "Mrs.", "Dr."]
2
3ticket.requestor.name = "Dr. Jane Doe"

To check against all prefixes

1list_of_prefixes.$ANY(prefix => ticket.requestor.name.$STARTS_WITH(prefix))
2
3# OR
4
5["Mr.", "Mrs.", "Dr."].$ANY(prefix => ticket.requestor.name.$STARTS_WITH(prefix))

Expected Result

1true

String Special Character Detection

Check if a string contains any characters that are not alphabetic letters or whitespace.

DSL Expression

text.$MATCH("[^a-zA-Z\\s]+", true).$LENGTH() > 0

This DSL:

  • Searches for one or more consecutive non-letter, non-whitespace characters
  • Returns true if any numbers or special characters are found
  • Returns false if the string contains only letters and whitespace

Use Cases

  • Form validation to ensure text fields contain only alphabetic characters
  • Identifying inputs that might require special handling or escaping
  • Security checks for potentially unsafe character sequences

Examples

InputResultReason
"Hello world"falseContains only letters and spaces
"Hello123"trueContains numbers
"Hello!"trueContains special characters
"Hello world!"trueContains special characters

Generate a hyphenated “Random” Number

This expression creates a pseudo-random number string formatted as a hyphen-separated sequence.

$CONCAT([($TIME().$INTEGER() * 6).$TEXT()[7:12], ($TIME().$INTEGER() * 12).$TEXT()[7:12],($TIME().$INTEGER() * 7).$TEXT()[7:12],($TIME().$INTEGER() * 23).$TEXT()[7:12]],"-")

This DSL:

  • Uses the current timestamp ($TIME().$INTEGER()) as a seed value
  • Multiplies by different prime-like numbers (6, 12, 7, 23) to create variation
  • Converts results to text and extracts specific digits using substring selection [7:12]
  • Concatenates the four number segments with hyphens as separators

How It Works

1

Get timestamp

$TIME().$INTEGER() gets the current Unix timestamp in milliseconds

2

Create variation

Multiplication by different factors produces varied number sequences

3

Extract digits

.$TEXT()[7:12] converts to text and extracts a consistent 4-digit segment

4

Join segments

$CONCAT(..., "-") joins the segments with hyphens

Example Output

"3542-7084-5799-1911"

Use Cases

  • Generating reference numbers or transaction IDs
  • Creating pseudo-random identifiers without requiring cryptographic security
  • Producing readable, hyphenated codes for display purposes

Not cryptographically secure — uses deterministic operations on time values. Will produce different values on each evaluation as time changes.