Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

Table of Contents
maxLevel2
excludeAdditional Resources|Related Links|Related Information

Object Examples

Conditional Expression

Expression


Code Block
$.hasOwnProperty('query.fred') ? $query.fred : 'not present in input'


DescriptionThis example is one way of doing an if-then-else expression.
Example

For example, to set a default pipeline variable in a document object, if you use the following expression for a mapper variable $lastname:

$.hasOwnProperty('lastname') ? $lastname : _lastname

$lastname has the value of $lastname as supplied by a document in the stream. If there is no document input, then $lastname is set to the _lastnameparameter value.


String Examples

Checking for a Non-empty String

Expression


Code Block
$customer.lastname.trim() || 'default'


DescriptionThe expression verifies if $customer.lastname and $customer.lastname.trim() has a value. If it does, then the value of $customer.lastname.trim() is applied to the target path, otherwise 'default' gets applied to the target path.


Checking for an Existing Value

Expression


Code Block
$.hasOwnProperty('customer.lastname') || 'default'


DescriptionThe expression verifies if $customer.lastname exists in the input document. It returns True if $customer.lastname exists, else it shows 'default' as a string and applies it to the target path. 

Checking for a Non-empty String and an Existing Value

Expression


Code Block
($.hasOwnProperty('customer.lastname') && $customer.lastname.trim()) || 'default''


DescriptionThe expression verifies if a property exists in the input document and if $customer.lastname and $customer.lastname.trim() provide a value. If it does then it applies its value to the target path, otherwise it applies 'default' to the target path.

Creating an Email Address from First Initial, Last Name

Expression


Code Block
$first_name.substr(0,1).toLowerCase()+$last_name.toLowerCase() + "@example.com"


Code Block
$first_name.charAt(0).toLowerCase()+$last_name.toLowerCase() + "@example.com"


DescriptionEither expression grabs the first letter of the $first_name field, converts it to lowercase, then adds it to the $last_name value and appends "@example.com" before writing it to $Email.

Date Examples

Creating and Formatting a Date in a Specific Timezone

Expression


Code Block
Date.now().toLocaleDateString('{\"timeZone\":\"PST\", "format":"yyyy-MM-dd"}')


DescriptionThe expression will create the current date time in the PST timezone and format its output into a string in the form of yyyy-MM-dd.

Formatting a Date to Include Letters

Expression


Code Block
Date.now().toLocaleDateTimeString('{"format":"yyyy-MM-dd\'T\'hh:mm:ss.SSS\'Z\'"}')


DescriptionThe expression creates the current date time and format its output into a string to include the letter "T" and "Z". Characters outside of normal SQLDate specials can be added by escaping them.

Creating an ISO-formatted Date in the Current Timezone

Expression


Code Block
Date.now().toLocaleDateString('{\"timeZone\":\"PST\"}')


DescriptionThe expression will create the current date time in the local time zone and format its output into a string for the ISO date time format.

Parsing a Date

Expression


Code Block
Date.parse($StandardDate)


DescriptionWill parse a string representation of $StandardDate into a DateTime object. The string representation is expected to have one of the following formats:
  • yyyy/MM/dd
  • yyyy/MM/dd HH:mm
  • yyyy/MM/dd HH:mm:ss
  • yyyy/MM/dd HH:mm:ss.SSS
  • MM/dd/yyyy
  • MM/dd/yyyy HH:mm
  • MM/dd/yyyy HH:mm:ss
  • MM/dd/yyyy HH:mm:ss.SSS
  • MMM dd, yyyy
  • EEE, dd MMM yyyy HH:mm:ss
  • EEE, dd MMM yyyy HH:mm:ss z
  • EEE, dd MMM yyyy HH:mm:ss 'GMT'Z
  • yyyy-MM-dd
  • yyyy-MM-dd'T'HH:mm:ss
  • yyyy-MM-dd'T'HH:mm:ssXXX
  • yyyy-MM-dd'T'HH:mm:ss.SSS
  • yyyy-MM-dd'T'HH:mm:ss.SSSXXX
  • yyyy-MM-dd HH:mm
  • yyyy-MM-dd HH:mm:ss
  • yyyy-MM-dd HH:mm:ssXXX
  • yyyy-MM-dd HH:mm:ss.SSS
  • yyyy-MM-dd HH:mm:ss.SSSXXX

Parsing a Non-standard Date

Expression


Code Block
Date.parse($NonStandardDate, "yyyy MM dd")


Code Block
Date.parse($nonstandard_datetime, "yyyy-MM-dd HH:mm:ss.SSS")


DescriptionThese examples parse the date into a DateTime object using the provided format.


Filtering Examples

Filtering for Two Possible Values

Expression


Code Block
$Priority == "Resolve Immediately" || $Priority ==  "High Attention"


DescriptionUsed in a Filter Snap, this expression finds only those items that have $Priority set to either Resolve Immediately or High Attention.

Filtering by Multiple Fields

Expression


Code Block
$Workflow == "Ready For Testing" && (($Priority == "Resolve Immediately") || ($Priority == "High Attention"))


DescriptionUsed in a Filter Snap, this expression finds only those items that are in the $Workflow step of Ready for Testing and $Priority is set to either Resolve Immediately or High Attention.

Filtering by Date within Timeframe

Expression


Code Block
$ClosedDate >= Date.now().minusHours(24)


DescriptionUsed in a Filter Snap, this expression finds only those items that have a $CloseDate within the last 24 hours.


Other Examples

Expression


Code Block
'<a href="' + $Link + '">' + $ID + '</a>'


DescriptionThis expression turns the value of the $ID field into a HTML link pointing to the location found in the $Link field.


Mapping Values to an Array

This series of expressions maps data from:

...