Common Examples of DSL Usage

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 [] , for this we need to use index accessors where 0 is the first element on the list. We will show you how to access and retrieve fields correctly.

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

Given a payload response:

{
  "id": ["123456"],
  "userPrincipalName":["[email protected]"],
  "displayName": ["John Doe"],
  "mail":["[email protected]"],
  "telephoneNumber": ["+1 234 567 890"],
  "mobile": ["+1 234 567 891"],
  "department": ["Information Technology"],
  "title": ["Senior Developer"],
  "physicalDeliveryOfficeName": ["HQ - Office 101"],
  "memberOf": [
    "CN=Developers,OU=Groups,DC=example,DC=com",
    "CN=ProjectX,OU=Groups,DC=example,DC=com",
    "CN=IT,OU=Groups,DC=example,DC=com"
  ],
  "accountStatus": ["Active"],
  "lastLogonTimestamp": ["2023-03-23T08:50:00Z"],
  "passwordLastSet": ["2023-01-15T09:33:00Z"],
  "thumbnailPhoto": ["https://example.com/photos/jdoe.jpg"]
}

To access the userPrincipalName field:

userPrincipalName[0]

Expected Result:


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 or pretty too look at if you have a list of 100s of users. Here’s how you can do it better.

Given:

emails = ["HeLlo", "WoRld"]

To lowercase all elements:

emails.$MAP(email => email.$LOWERCASE())

# or

["HeLlo", "WoRld"].$MAP(email => email.$LOWERCASE())

Expected Result:

["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 The stream operator will match our ticket with a list of strings or elements.

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

Given:

list_of_prefixes = ["Mr.", "Mrs.", "Dr."]

ticket.requestor.name = "Dr. Jane Doe"

To check against all prefixes

list_of_prefixes.$ANY(prefix => string_to_check.$STARTS_WITH(prefix))

# OR

["Mr.", "Mrs.", "Dr."].$ANY(prefix => ticket.requestor.name.$STARTS_WITH(prefix))

Expected Result:

true