No Results
Advanced Rule Mode: JavaScript Rule Expression

edgeCore utilizes AngularJS’s $parse to parse the JavaScript rules entered by users. The $parse expects AngularJS Expressions which have some notable restrictions on what can be entered:

Full documentation on AngularJS Expressions can be found here.

To help users to create more powerful expressions and workaround the above limitations, the following JavaScript libraries are accessible in the rule evaluation context:

Underscore.js

Version: 1.8.3

Reference: _

Used for array-based manipulations.
_.uniq(var1.split(':')).length > 4
_.reject(var2.split(':'), StringUtil.createFunction('return parseInt(num) % 2 === 0;', ['num']) ).length === 3
More information can be found on this link.

Underscore.string

Version: 3.1.1

Reference: s

Used for string-based manipulations.

s.reverse(var1) === 'esrever'
s.titleize(var2) === 'Title Abc World'

More information can be found on this link.

Moment.js

Version: 2.17.1

Reference: moment

Used for date/time-related manipulations.

moment(var1).isLeapYear()
moment(var2).isValid()

More information can be found on this link.

JavaScript Math

Reference: Math

Math functions provide the browser’s native JavaScript Engine.

Math.round(var1) > 3
Math.abs(var2) <= 56

More information can be found on this link.

JavaScript Console

Reference: console

Used for testing purposes.
The rule will not match and should be placed as 1st rule if you want it to be run for every record.

console.log(moment(var1).isLeapYear())
console.log(s.reverse(var1) === 'esrever')

More information can be found on this link.

StringUtil

This is an internal library supplied by edgeSuite that mimics the browser’s native JavaScript Engine string methods to work around the AngularJS Expression limitations stated above:

search(subjectString: string, regExpString: string, regExpFlags?: string): number
match(subjectString: string, regExpString: string, regExpFlags?: string): Array<string>
replace(subjectString: string, replaceString: string, regExpString: string, regExpFlags?: string): string
createRegExp(regExpString: string, regExpFlags?: string): RegExp
createFunction(functionBody: string, argumentList?: Array<string>): Function

var1.search(StringUtil.createRegExp('^parent 001', 'i')) > -1
_.reject(var2.split(':'), StringUtil.createFunction('return parseInt(num) % 2 === 0;', ['num']) ).length === 3
StringUtil.match(var3, "\\d").index === 7
StringUtil.replace(var4, "$1-child", "^(parent)") === 'parent-child 1'


Terms | Privacy