Simflofy Expression Language
Overview
Simflofy uses a version of the JEval project to handle expressions. Expressions can be used in many places in Simflofy. Specifically they are used for calculated fields on the mapping page, but tasks and connectors can use them in their configuration pages too. The filter task is another good example.
An expression allows you to create values based on some formula or set of function calls. This can be used in a host of use cases to solve many problems including:
- Formatting data
- Value based on result of a decision
- Setting default values
- Creating data from other data
Expression Basics
An expression is just a series of Strings, Numbers, Function Calls, and Operators put together by the administrator resulting in a value.
Strings or Numbers or Booleans
Strings are surrounded with ' '. If something is not surrounded with a ', then it's treated as a number. This will result in an error if you try to convert a string to a number.
'Mark' is a string
Mark is a number, but will cause an error.
'0' is a String
0 Is the number 0.
Booleans result in 1.0 or 0.0 where 1.0 is true and 0.0 is false.
'mark' == 'mark' would result in 1.0, or true. Whereas
'mark' == 'nathan' would result in 0.0.
Variables
Variables are either part of the Repository Document, Version History, or Fields from a Repository.
info
You access a variable using the following format: '#{rd.path}'
Tasks search for #{
when detecting calculated field. The first portion
identifies where to find the data.
Repository Document == rd
Version History == version
Fields == field or nothing
Examples:
#{rd.mimetype}
#{version.label}
Where document is the type:
#{document.myfield}
, which is exactly the same
as #{field.document.myfield}
See below for a full reference of all rd and version variables available.
Function Calls
You call functions with no ' ' such as:
now()
Most functions are camel case. So first letter is lower case, start of each syllable after that is upper case:
toLower()
, startsWith()
, etc..
String Functions
Full list of String functions with example:
startsWith('test.pdf', 'test', 0)
substring('test.pdf', 3, length('test.pdf'))
toUpperCase('test.pdf')
indexOf('test.pdf', '.', 0)
length('test.pdf')
replace('test.pdf', 'p', 'x')
concat('test.pdf', 'test.xml')
equals('test.pdf', 'test.PDF')
equalsIgnoreCase('test.pdf', 'test.PDF')
compareToIgnoreCase('test.pdf', 'test.xml')
compareTo('test.pdf', 'test.xml')
charAt('test.pdf', 1)
endsWith('test.pdf', '.xml')
toLowerCase('Hello World!')
trim('abc ') + 'd'
lastIndexOf('abcabcabc', 'abc', 8)
eval(1 + 2)
Math Functions
Full list of math functions with example:
asin(1)
atan(2.2)
atan2(2.2, 2.3)
ceil(2.2)
cos(2.1)
exp(2.2)
floor(2.2)
IEEEremainder(2, 6)
log(2)
max(2.2, 3.5)
min(2.2, 6.6)
pow(2, 5)
random(6)
rint(2)
round(2)
sin(2)
sqrt(9)
tan(2)
toDegrees(45)
toRadians(44)
abs(-1)
Custom Functions
If the first argument is blank, use the second argument.
isblank('#{rd.path}', '/my/default/path')
Returns the date at the time the job is run
now()
If the first date string is not a valid date, it will use the second date
string as the default. This can be now()
, another hard coded String, or some
other function or set of functions.
toDate('Date String', 'Default Date')
Creating your own custom functions
Operators
The normal Boolean, number, and string operators for Java work with Simflofy Expressions:
+
-
&&
!
||
/
==
)
(
)=
(=
%
*
!=
Repository Document Variables
All variables with Simflofy Variable Resolvers are case-insensitive.
Repository Document
CreatedDate
ModifiedDate
FileName
FileLength
ID
MimeType
ObjectType
Path
SimflofySourceRepositoryID
Version
totalVersions
label
seriesId
isLatest
isMajor
listId
Examples
#{rd.CreatedDate}
#{rd.ModifiedDate}
#{rd.FileName}
#{rd.FileLength}
#{rd.ID}
#{rd.MimeType}
#{rd.ObjectType}
#{rd.Path}
#{rd.SimflofySourceRepositoryID}
#{version.totalVersions}
#{version.label}
#{version.seriesId}
#{version.isLatest}
#{version.isMajor}
#{version.listId}
Custom Fields you need to prepend with field
#{field.myObject.myCustomField}
#{rd.filename}
+ _
+ version.label
#{mytype.claimid}
+ _
+ #{mypolicy.policynumber}
Filters expect a Boolean result, 1.0 or 0.0. So you can do things like:
#{rd.mimeType}
== text/html
Nested Functions
You can also nest functions. A good example is toDate:
toDate('#{rd.createddate}', now())
This results in rd.created
date being formatted into UTC format, but if for
some reason Simflofy detects an invalid date it will use the result of now()
instead.
Related Articles:
Simflofy Integration Job Mappings
Mapping Audits Report
Integration Job Tasks