0% found this document useful (0 votes)
98 views65 pages

MVEL Expression Language Studio

The document provides a comprehensive overview of the MVEL Expression Language, detailing its syntax, operators, assignment methods, and various functionalities within the Workday ESB's Assembly framework. It includes sections on naming conventions, integration attributes, control flow, and MVEL functions, among others. Additionally, the document serves as a guide for using MVEL effectively in manipulating context variables and Java objects.

Uploaded by

NesNosss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views65 pages

MVEL Expression Language Studio

The document provides a comprehensive overview of the MVEL Expression Language, detailing its syntax, operators, assignment methods, and various functionalities within the Workday ESB's Assembly framework. It includes sections on naming conventions, integration attributes, control flow, and MVEL functions, among others. Additionally, the document serves as a guide for using MVEL effectively in manipulating context variables and Java objects.

Uploaded by

NesNosss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 65

MVEL EXPRESSION LANGUAGE-STUDIO

MVEL Expression Language

Table of Contents
1 MVEL Expressions................................................................................................... 5
1.1 Naming Conventions................................................................................................5
1.2 MVEL Autocomplete:............................................................................................... 5
1.3 MVEL 2.x expressions............................................................................................. 6
2 Operators...................................................................................................................8
2.1 Unary Operator:....................................................................................................... 8
2.2 Comparison Operator...............................................................................................8
2.3 Logical Operators...................................................................................................10
2.4 Arithmetic Operators..............................................................................................11
2.5 Other Operators.....................................................................................................12
3 Assignment............................................................................................................. 13
3.1 Literals:.................................................................................................................. 13
3.2 Difference b/w Assignment and Equal...................................................................14
4 Launch Parameter:................................................................................................. 15
4.1 Simple Type Parameter:........................................................................................ 15
4.2 Reference Type Parameter:...................................................................................16
4.3 Convert Array Values to String...............................................................................17
4.4 Date From Launch Parameter................................................................................19
5 Integration Attributes:............................................................................................20
5.1 Simple Type Parameter:........................................................................................ 20
5.2 Reference Type Parameter:...................................................................................20
5.3 Convert Array Values to String...............................................................................20
6 Integration MAP.................................................................................................22
7 Sequence Generator...............................................................................................24
8 Da: Document Accessor(To retrieve Input File)...................................................25
9 Evaluate Xpath: parts[]........................................................................................26
9.1 Format Date........................................................................................................... 26
9.2 Format Number......................................................................................................27
9.3 Right/Left Justification (Padding)...........................................................................27
10 Mvel Functions........................................................................................................28
10.1 Substring............................................................................................................. 28
10.2 Index of................................................................................................................28
10.3 Substring-before..................................................................................................29

2
MVEL Expression Language

10.4 Substring-after.....................................................................................................29
10.5 Replace or Translate...........................................................................................29
10.6 Contains.............................................................................................................. 29
10.7 Normalize space:.................................................................................................29
10.8 Length:................................................................................................................ 30
10.9 Concat................................................................................................................. 30
10.10 Substring and Contains.................................................................................... 30
10.11 Equal Ingnore Case:.........................................................................................30
10.12 Aggregate Function.......................................................................................... 30
10.13 Lowercase........................................................................................................ 31
10.14 UpperCase:.......................................................................................................31
10.15 Starts With........................................................................................................31
10.16 Ends with.......................................................................................................... 31
10.17 Clear and remove.............................................................................................32
10.18 Append............................................................................................................. 32
11 Control Flow: MVEL Expression Capabale Property:..........................................33
11.1 if...........................................................................................................................33
11.2 If else...................................................................................................................33
11.3 else if................................................................................................................... 33
12 Ternary Operator:................................................................................................... 34
12.1 Ternary statements:............................................................................................ 34
12.2 Nested Ternary Statements:................................................................................34
13 Hash Map and Array list.........................................................................................35
13.1 Hash Map............................................................................................................35
13.2 Array List to Hash Map........................................................................................35
13.3 List to For Loop................................................................................................... 36
13.4 Remove Duplicates Using Array List...................................................................37
13.5 CleanUp or remove Hash Map............................................................................37
14 MVEL Template Capabale Property on webservice.............................................39
14.1 Foreach-Statement Example on webservice.......................................................39
14.2 If-Statement Example on webservice..................................................................39
15 Before and After Splitter........................................................................................40
15.1 Last Row or Employee in Batch..........................................................................40
15.2 To find total employees from input file.................................................................40
15.3 To find Success count on employee incase of inbound......................................40
15.4 To find Error Count on employee incase of inbound...........................................40

3
MVEL Expression Language

15.5 Local-out condition Execute when.......................................................................41


15.6 In put message....................................................................................................41
16 Studio Specific MVEL Expression Table..............................................................42
17 USEFUL Links:........................................................................................................50

4
MVEL Expression Language

1 MVEL Expressions

MVEL is an incredibly powerful expression language which is tightly integration into the
Workday ESB's Assembly framework. With MVEL is it possible to construct powerful
and flexible expressions for manipulating Assembly context variables and associated
Java objects, but as ever, with great power comes great responsibility!
1.1 Naming Conventions

A large number of properties are added to the mediation context by the ESB and some
of the shared components. Prefixing the properties you declare within your integration
name will making them easier to find when debugging the assembly and add a
conceptual scope to the properties. For example:
props['payforce.company.name']
If you set properties to contain the values of integration attributes, use "ia" as the prefix.
For example:
props['ia.include.job.code']
For Launch parameter : props['lp.include.job.code']
Always ensure that your property names are meaningful. Do not be tempted to
abbreviate property names. Descriptive and meaningful property names aid readability,
and reduce the overall cost of maintaining the code over subsequent revision.

1.2 MVEL Autocomplete:

Need help with the syntax of particular operations or with the names of
elements in your flow?, you can always access MVEL suggestions by
pressing Ctrl + Space Bar.

5
MVEL Expression Language

1.3 MVEL 2.x expressions may consist of:

 Property expressions

 Boolean expressions

 Method invocations

 Variable expression

 Function definitions

1.3.1 Property Expression


A utility adapter for gaining access to message properties using the
AssemblyUtils.PropertyMapAdapter class.

The following expression is equivalent to

context.getProperty('myProperty')

6
MVEL Expression Language

but less verbose:


props.myProperty

The following expression returns the property value set by a custom Spring bean:
Syntax for property: props['bean.property']

1.3.1.1 Multiple statements

You may write scripts with an arbitrary number of statements using the
semi-colon to denote the termination of a statement. This is required in all
cases except in cases where there is only one statement, or for the last
statement in a script.
statement1; statement2; statement3

EG: props['user.name']= 'jeeva'; props['user.id']= '20558'; props['user.acc']= 'jthangaraj'

1.3.2 Variable Expression

Provides access to the MessageContextVariables interface as a Map. To


access variables, use the following notation:

Syntax:
vars['payroll.payee.in.extract']

props[‘user.name’] = vars['payroll.payee.in.extract']

7
MVEL Expression Language

8
MVEL Expression Language

2 Operators

2.1 Unary Operator:


2.1.1 new
Object instantiation or instance of class and allocating memory to the object.
props['p.ee.hash.map'] = new java.util.HashMap()

props['p.error.log'] = new java.lang.StringBuffer();

props['p.array.list'] = new java.util.ArrayList()

2.2 Comparison Operator


2.2.1 Equal: ==
Equality Check. Checks to see if the values on both sides of the operator are equal.
Unlike Java, this is not an identity check
Assigning props['count'] = 10; props['employee.count'] = 10

props['emp'] = props['count'] == props['employee.count']

EG: if props['count'] is equal to props['employee.count'], props['emp'] is true

10 == 10 then true

Result: props['emp'] = true

2.2.2 Not Equal: !=


Not Equals Check. Checks to see if the values on both sides of the operator are not
equal.

Assigning props['count'] = 5; props['employee.count'] = 5

props['emp'] = props['count'] != props['employee.count']

EG: if props['count'] is not equal to props['employee.count'], props['emp'] is true

Result: 5 != 5 then false so props['emp'] = false

9
MVEL Expression Language

2.2.3 Greater Than : >


Greater Than Check. Checks to see if the value on the left side of the operator is
greater than than value on the right.

props['count'] = 10; props['employee.count'] = 5

props['emp'] = props['count'] > props['employee.count']

Result: props['emp'] = true

2.2.4 Less Than: <

Less Than Check. Checks to see if the value on the left side of the operator is
less than value
props['count'] = 10; on the right.
props['employee.count'] =5

props['emp'] = props['count'] < props['employee.count']

Result: props['emp'] = false

2.2.5 Greater than or Equal to: >=


Greater Than or Equal. Checks to see if the value on the left hand side is greater than
or equal to the value on the right.
props['count'] = 10; props['employee.count'] = 5

props['emp'] = props['count'] >= props['employee.count']

Result: props['emp'] = true

2.2.6 Less than or Equal to: <=


Less Than or Equal. Checks to see if the value on the left hand side is less than or
equal to the value on the right.
props['count'] = 10; props['employee.count'] = 5

props['emp'] = props['count'] <= props['employee.count']

Result: props['emp'] = false 10


MVEL Expression Language

2.2.7 Contains
Value Containment Check. Checks to see if the value on the left contains the value on
the right

props['count'] = 'Worker'; props['employee.count'] = 'Contingent Worker'

props['emp'] = props['count'] contains props['employee.count']

Result: props['emp'] = true. Since both property has value as Worker

2.3 Logical Operators


2.3.1 Logical And: And , &&
Logical AND. Checks to see that the values on both sides of the operator are true.

props['count'] && props['employee.count']

props['count'] and props['employee.count']

if(props['count'] == true && props['employee.count'] != true){ props['employee'] = 'Active' ;}

2.3.2 Logical OR : ||
Logical OR. Checks to see if either the value on the left or the right is true.

props['count'] || props['employee.count']

if(props['count'] == true || props['employee.count'] != true){ props['employee'] = 'Active' ;}

11
MVEL Expression Language

2.3.3 Chained OR : or
Chained OR. Checks a sequence of values for emptiness and returns the first non-
empty value
props['count'] = 'Employee' props['employee.count'] = 'Contingent'

props['emp'] = props['count'] or props['employee.count']

Result: props['emp'] = 'Employee' since first property has value so it won’t check next property.

props['count'] = null props['employee.count'] = 'Contingent'

props['emp'] = props['count'] or props['employee.count']

Result: props['emp'] = 'Contingent' since first property is null So it checked next property and
returned it value.

2.4 Arithmetic Operators

2.4.1 Addition: +
props['count'] = 10; props['employee.count'] = 5

props['emp'] = props['count'] + props['employee.count']

Result: props['emp'] = 15

2.4.2 Subtraction: -
props['count'] = 10; props['employee.count'] = 5

props['emp'] = props['count'] - props['employee.count']

Result: props['emp'] = 5

12
MVEL Expression Language

2.4.3 Division: /
props['count'] = 4; props['employee.count'] = 2

props['emp'] = props['count'] / props['employee.count']

Result: props['emp'] = 2

2.4.4 Multiplication: *

props['count'] = 4; props['employee.count'] = 2

props['emp'] = props['count'] * props['employee.count']

Result: props['emp'] = 8

2.4.5 Modulus: %

props['count'] = 9; props['employee.count'] = 4

props['emp'] = props['count'] % props['employee.count']

Result: props['emp'] = 1 since reminder is 1

2.5 Other Operators


2.5.1 String Concatenation: +

String Concatenation. Overloaded operator for concatenating two strings


together.

props['emp']="Contingent"; props['emp1']="Worker"

props['employee'] = props['emp'] + props['emp1']


13
Result: props[' employee '] = ContingentWorker
MVEL Expression Language

2.5.2 Numeric Concatenation: #

props['num'] = 12; props['num1'] = 56;

props['num.concat'] = props['num'] # props['num1']

Result: props['num.concat'] = 1256

2.5.3 Assignment: =
Assignment. Assigns the value on the right to the variable on the left.
props['num'] = 12

props['num'] = true

props['emp'] = 'employee' or props['emp'] = " employee"

props['emp'] = ''

14
MVEL Expression Language

3 Assignment

MVEL allows you assign variable in your expression, either for extraction
from the runtime, or for use inside the expression.

3.1 Literals:

A literal is used to represent a fixed-value in the source of a


particular script.

3.1.1 Strings

Assigning Literals to property:

String literals may be denoted by single or double quotes.

"This is a string literal"

'This is also string literal'

props[‘user.name’] = 'This is also string literal'

Assigning xml Tags to properties:

props[‘user.name’] = '<hello>world</hello>'

props['employee_id_string'] = '<wd:Employee_Reference><wd:Integration_ID_Reference><wd:ID
wd:System_ID="WD-EMPLID">' + props['file_empid'] +
'</wd:ID></wd:Integration_ID_Reference></wd:Employee_Reference>'

props['get_worker_employee_id_string'] = '<wd:ID wd:type="Employee_ID">' + props['file_empid'] +


'</wd:ID>'

Assigning mimeType:

props[‘user.name’] = 'Hello World', 'text/xml'

15
MVEL Expression Language

3.1.2 Numerics
Assigning Numeric Value:

props['count'] = 0

3.1.3 props['count']
Boolean = 1+2
Boolean literals are represented by the reserved keywords true and
false.

Assigning Boolean value to property:

props['count'] = true

props['count'] = false

3.1.4 Null or nil


The null literal is denoted by the reserved keywords null or nil or '' or
empty.
Assigning null value to property:

props['count'] = null

props['count'] = nil

props['count'] = ''

props['count'] = empty

3.2 Difference b/w Assignment and Equal

Difference b/w Assignment and Equal

Assignment: Here assigning or storing value for property

props['count'] = 0

props['count'] = empty

props['count'] = true

Equal: Here checking or testing this property is equal to that value or not
16
props['count'] == 0
MVEL Expression Language

17
MVEL Expression Language

4 Launch Parameter:

Mvel helper class is lp: Provides access to the integration launch parameters.
The lp variable is only applicable to Workday internal server and integration
Cloud developers.

4.1 Simple Type Parameter:

Mvel helper class for launch parameter is lp and to get data from simple type launch
parameter need to use getSimpleData('label') and here label should be your
prompt name “Tax Frequency Value”.

Type lp. then press CNTRL + Space Bar then you will get all related
methods.

EG: lp.getSimpleData('label')

props['lp.cc.wid']=lp.getSimpleData('Tax Frequency Value')

if we want to pass this below simple type prompt property value to Raas
Report prompt should convert it to string then you call this property to raas
call to give input to your raas report prompt.

props['lp.cc.wid']=lp.getSimpleData('Cost Centers')

props['get.cc.wid.prompt'] = props['lp.cc.wid'].toString()

18
MVEL Expression Language

Raas Report Mvel Property:

@{intsys.reportService.getExtrapath('costcenterpromptvaluegiven')}?Cost_Center!
WID=@{props['get.cc.wid.prompt']}

4.2 Reference Type Parameter:

Reference Type Parameter is nothing but prompt on your webservices fields. By clicking
yellow arrow mark in the below screenshot you can access webservice fields. There to
find the fields directly you can select CRF(class report fields) and you can type the fields
on search bar or else you can take it by expanding the webservice requests.

To use single instance reference type prompt value we need to


use getReferenceData('label', 'type') method.

props['lp.run.category'] = lp.getReferenceData('label', 'type')

Label is your prompt name(see above screenshot) : Run Category


Type

19
MVEL Expression Language

Type can be: Reference ID or WID

props['lp.run.category'] = lp.getReferenceData('Run Category Type', 'Run_Category_ID')

or

props['lp.run.category'] = lp.getReferenceData('Run Category Type', ‘WID’)

4.3 Convert Array Values to String

To convert an array list to a string, the following can be used (Array of Workers
converted to a string to be used in a REST URL for RaaS):

When selecting multiple input in prompt.

20
MVEL Expression Language

To use Multi Instance reference type prompt value we need to


use any one of the below method
props['lp.cc.wid'] = lp.getWIDs('label')
or
props['lp.cc.wid'] = lp.getReferenceDataList('label', 'type')

To get the multiple values or list of values selected in Launch Parameter prompt use below
methods :

props['lp.cc.wid'] = lp.getWIDs('Cost Centers')

or

props['lp.cc.wid'] = lp.getReferenceDataList('Cost Centers', 'WID')

output: [6cb77610a8a543aea2d6bc10457e35d4,
bc33aa3152ec42d4995f4791a106ed09, 80938777cac5440fab50d729f9634969,
c4f78be1a8f14da0ab49ce1162348a5e]

Should convert this output format to following format which would be supported by raas
report. To convert as below should use below property.

6cb77610a8a543aea2d6bc10457e35d4!bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!c4f78be1a8f14da0ab49ce1162348a5e

Convert Array Values to String

props['get.cc.wid.prompt']=props['lp.cc.wid']!=empty?
util.listToCommaDelimString(context.getProperty('lp.cc.wid')).replace(',','!') : null

21
MVEL Expression Language

should pass this property props['get.cc.wid.prompt'] to raas Report now. will now be a
string of cost center WIDs. The commas (,) are replaced by exlamation marks (!) as this
is how you separate IDs in a REST URL for Workday RaaS end points.
output: 6cb77610a8a543aea2d6bc10457e35d4!bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!c4f78be1a8f14da0ab49ce1162348a5e

@{intsys.reportService.getExtrapath('costcenterpromptvaluegiven')}?Cost_Center!
WID=@{props['get.cc.wid.prompt']}

In background input should go to raas report in below format:

customreport2/medtronic4/jthangaraj/MyCustomReport?CostCenters!
WID=6cb77610a8a543aea2d6bc10457e35d4!
bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!c4f78be1a8f14da0ab49ce1162348a5e

4.4 Date From Launch Parameter


4.4.1 To Find Current Effective Date:

props['date'] = lp.getDate('label')

props['date'] = lp.getDate('Current Effective Date and Time')

22
MVEL Expression Language

4.4.2 To Find Last Successful Date Time:

props['date'] = lp.getSimpleData('label')or props['date'] = lp.getDate('label')

props['lp.lastsuccessful.datetime']= lp.getSimpleData("Last Successful DateTime")

props['lp.lastsuccessful.date']=props['lp.lastsuccessful.datetime'].substring(0,10)

23
MVEL Expression Language

5 Integration Attributes:

Mvel helper class is intsys: Provides access to the integration system configuration
for this assembly.

5.1 Simple Type Parameter:

To Access simple type integration attribute prompt,


intsys.getAttribute('label') method should be used.

Syntax: props['sftpEndPoint']=intsys.getAttribute('label')

props['sftpEndPoint']=intsys.getAttribute('SFTP Endpoint')

5.2 Reference Type Parameter:

To Access Reference type single instance integration attribute prompt,


intsys.getAttributeReferenceData('label', 'type')method should be used.

Syntax: props['pgp.key'] = intsys.getAttributeReferenceData('label', 'type')

props['pgp.key'] = intsys.getAttributeReferenceData('PGP Public Key', 'WID')

props['ia.run.category']=intsys.getAttributeReferenceData('RunCategoryType','Run_Category_ID')

or

props['ia.run.category']=intsys.getAttributeReferenceData('RunCategoryType','WID')

24
MVEL Expression Language

5.3 Convert Array Values to String

To convert an array list to a string, the following can be used (Array of Workers
converted to a string to be used in a REST URL for RaaS):
To Access Reference type multi instance integration attribute prompt,
intsys.getAttributeReferenceDataList ('label', 'type') or intsys.getWIDs('label')
method should be used.
props['ia.ledger.account.no.emp'] = intsys.getAttributeReferenceDataList('Ledger Account No
Employee Detail', 'WID')

props['ia.ledger.account.no.emp'] = intsys.getWIDs('Ledger Account No Employee Detail')

props['get.ledger.account.no.emp'] =props['ia.ledger.account.no.emp'] != empty ?


util.listToCommaDelimString(context.getProperty('ia.ledger.account.no.emp')).replace(',','|') : null

5.3.1 Report URL:


@{intsys.reportService.getExtrapath('costcenterpromptvaluegiven')}?ledger
account!WID=@{props['get.ledger.account.no.emp']}

5.3.2 How to get Integration Attribute or any MVEL Property to


XSLT:
In XSLT or STX, first declare the "is" namespace in stylesheet: Then call the
method from an XPath expression

xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"

is:getIntegrationAttributeValue('Entity Name')

(note the alternative mechanism for passing attribute values into XSLT in the
next paragraph):

25
MVEL Expression Language

props['ia.include.job.code'] = intsys.getAttribute('Include Job Code')

Declare a stylesheet parameter in the XSLT as follows:Label of above property should be


called in a global variable in xslt to call that mvel property to xslt as below.

<xsl:param name="ia.include.job.code" />

26
MVEL Expression Language

6 Integration MAP

To Retrieve External Value:

Syntax:

props['gender.type'] = intsys.integrationMapLookup('map_name', 'external_value')

simpleTextTypeMap

props['ia.simple.map'] = intsys.integrationMapLookup('simpleTextTypeMap', 'M')

enumTypeMap

props['ia.enum.map'] = intsys.integrationMapLookup('enumTypeMap', 'Active')

referenceTypeMap

props['ia.reference.map'] = intsys.integrationMapLookup('referenceTypeMap', 'Telephone')

To Retrieve Internal Value:

Syntax:

props['ia.label'] = intsys.integrationMapReverseLookup('map_name', 'key')

simpleTextTypeMap

props['ia.simple.map'] = intsys.integrationMapReverseLookup('simpleTextTypeMap', 'Male')

27
MVEL Expression Language

enumTypeMap

props['ia.enum.map'] = intsys.integrationMapReverseLookup('enumTypeMap', 1)

referenceTypeMap

props['ia.reference.map'] = intsys.integrationMapReverseLookup('referenceTypeMap', 'P')

How to access Integration Map in XSLT:

In XSLT or STX, first declare the "is" namespace in stylesheet: Then call the method
from an XPath expression
xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"

is:integrationMapReverseLookup('Earnings Code', 'EARNING_CODE')

is:getIntegrationMapValue('Time_Off_Codes','Time_Off_Type_ID')

(note the alternative mechanism for passing attribute values into XSLT in the next
paragraph):

props['ia.simple.map'] = intsys.integrationMapLookup('simpleTextTypeMap', 'M')

SDeclare a stylesheet parameter in the XSLT as follows:

<xsl:param name="ia.simple.map" />

<xsl:value-of select="$ia.simple.map"></xsl:value-of>

28
MVEL Expression Language

29
MVEL Expression Language

7 Sequence Generator

which you can use to generate unique, sequenced file names. If your integration system
needs to create a different file name each time it runs, you can associate a sequence
generator service with your Workday-in transport to generate the file name. You define
the service with one or more named sequencers in Studio, then configure the
sequencers in Workday.

props['lp.batch.id.seq'] = lp.getSequencedValue('label')

props['lp.batch.id.seq'] = lp.getSequencedValue('BatchIDSequence')

30
MVEL Expression Language

8 Da: Document Accessor(To retrieve Input File)

Within a Workday Studio integration, you can use the Document Accessor
(da) variable within an eval step's MVEL expression to access a document or
input file from tenant or some sftp server.

The following example gets a document from the Integration Event with filename
eib_transform_output.txt and adds is as a variable named var1:

da.toVar('eib_transform_output.txt', 'var1')
or

if (da.size() > 0 ) {da.toVar(0, "wd.retrieve.variable")}

31
MVEL Expression Language

9 Evaluate Xpath: parts[]

Parts[] : Provides array-based access to message parts using the


MessageAdapter interface. The root part is part 0, the first attachment is
part 1.

For example, to get the content of first attachment, the root part:

parts[0].text

To get the content of the second attachment:

parts[1].text

Syntax: props['eval.xpath'] = parts[0].xpath('xpath')

props['eval.xpath']=parts[0].xpath('/env:Envelope/env:Body/wd:Get_Workers_Response/wd:Response_Data/
wd:Worker/wd:Worker_Data/wd:User_ID')

Syntax with namespace: props['myPropName'] = parts[0].xpath('xpath', 'namespaces')

props['namespace.row'] = 'wd http://workday.com'

props['row.employee.id'] = parts[0].xpath('payment_Offcycle/EMPLID',props['namespace.row'])

9.1 Format Date

To format a date using MVEL instead of XSLT, it can be done using the following
example (yyyy-MM-dd converted to MM/dd/yyyy):

props['p.input.date'] = '2013-10-03'

props['p.parsed.date'] = new java.text.SimpleDateFormat("yyyy-MM-dd").parse(props['p.input.date'])

props['p.date.formatted'] = new java.text.SimpleDateFormat("MM/dd/yyyy").format(props['p.parsed.date'])

32
MVEL Expression Language

9.2 Format Number

To format a number using MVEL instead of XSLT, it can be done using the following
example (##0.0000 converted to ##0.00):

props['p.employee.salary'] = parts[0].xpath("wd:Report_Entry/wd:Total_Annual_Base_Salary") /* let's say this is


1234.5678 */

props['p.parsed.number'] = new java.text.DecimalFormat("##0.00").parse(props['p.employee.salary'])

props['p.number.formatted'] = new java.text.DecimalFormat("##0.00").format(props['p.parsed.number'])

9.3 Right/Left Justification (Padding)

To justify, or pad, a value using MVEL the following can be used

org.apache.commons.lang.StringUtils.leftPad( '1234', 10,'0') /*(str inputValue, int size, str paddingChar) */

Output: 0000001234

org.apache.commons.lang.StringUtils.rightPad( '1234', 10,'0') /*(str inputValue, int size, str paddingChar) */

Output: 1234000000

33
MVEL Expression Language

10 Mvel Functions

10.1 Substring

Returns the substring from the start position to the specified length. Index of the first
character is 1 here. If length is omitted it returns the substring from the start position to
the end

Example: substring('Beatles',1,4)
Result: 'Beat'
For String:

props['lastupddttm'] = 'Beatles'

props['lastupd_dt'] = props['lastupddttm'].toString().substring(1, 4)

Result: props['lastupd_dt'] = Beat

For Integer:

props['birth.date'] = lp.getDate('lp.mydate') which returns 2011-03-24-07:00

props['Birth.Date']=props['birth.date'].substring(0,10)

Result: props['Birth.Date'] = 2011-03-24

props['payment'] = parts[0].xpath("//Payment_Date").substring(2)

Result: parts[0].xpath("//Payment_Date") which returns 2014-03-30T00:00:00.000-07:00

props['payment'] = 14-03-30T00:00:00.000-07:00

34
MVEL Expression Language

10.2 Index of

Returns the positions within the sequence of items that are equal to the
search item argument. Index starts with 0 here.

Example: index-of ('12-10','-')

Result: 2
props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")

10.3 Substring-before
parts[0].xpath("//Payment_Date") returns 2014-03-30T00:00:00.000-07:00

props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")

Result: props['p.index.separator'] = 4 (Note: takes first hypen position )

props['p.substring.before']= parts[0].xpath("//Payment_Date").substring(0,props['p.index.separator']);

Result: 2014

10.4 Substring-after
props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")

props['p.substring.after']=parts[0].xpath("//
Payment_Date").substring(props['p.index.separator']+1);

10.5 Replace or Translate

props['Worker_Type'] = "Active_Worker"

props['Worker'] = props['Worker_Type'].toString().replace("_","Contingent ")

Result: props['Worker'] = ActiveContingentWorker

10.6 Replace all non-numeric characters


replace all non-numeric characters with a blank value

input: gray12345-2014.pdf

props['p'] = gray12345-2014.pdf
35
props['p.cleaned'] = props['p'].replaceAll('[^0-9]','')

output: 123452014
You could then substring the first 5 characters:

MVEL Expression Language

10.7 Contains

props['managerNotInWDError']=props['manager.errmessageback'].toString().contains('not a valid ID')

Example: Employee Id is not a valid id contains not a valid id string then returns true

10.8 Normalize space:

Removes leading and trailing spaces from the specified string,


and replaces all internal sequences of white space with one and
returns the result. If there is no string argument it does the
same on the current node

props['row.plan.id']= parts[0].xpath("normalize-space(/record/PLAN_ID)")

Example:normalize-space(' The XML ')


Result: 'The XML'

10.9 Length:
props['EmployeeID'] = '20558'

props['emp.length'] = (props['EmployeeID'].length()

Result: props['emp.length'] = 5

36
MVEL Expression Language

10.10 Concat

concatenating two strings together.

props['lp.batch.id.seq']= lp.getSequencedValue('BatchIDSequence').toString().concat(props['Location'])

10.11 Substring and Contains


props['Period_end']=parts[0].xpath('substring(/rd:Report_Data/rd:Report_Entry/
rd:Pay_Group_Detail[contains(rd:Instance/@rd:Descriptor,"Bi-weekly")]/rd:End_Current_Period,1,10)')

10.12 Equal Ingnore Case:

parts[0].xpath("//Payment_Date") returns 2014

props['payment']=parts[0].xpath("//Payment_Date").equalsIgnoreCase('2014')

EG: 2014 equals 2014

Result: props['payment']= true (If it equals will return true otherwise false)

10.13 Aggregate Function


10.13.1 Sum
EG: Do sum salary of all the employees on xml message

props['total.taxes.paid.processed']= parts[0].xpath("sum(//Total_SOT_Processed)")

10.13.2 Count
EG: Do count the number of nodes
props['multiple.state.tax.election']=parts[0].xpath("count(/Worker_Tax_Election/State_Tax_Election)")
count with namespace used:

props['total_message_count_from_report']=
parts[0].xpath("count(Cost_Center_Data/Cost_Centers)",props['namespace.row'])

37
MVEL Expression Language

10.14 Lowercase

props['lowercas']=parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').toLowerCase()

EG: W_MED to w_med

10.15 UpperCase:

props['payment'] = parts[0].xpath("/Off-cycle_Input_Data/Deduction_Reference/ID ").toUpperCase()

EG: w_med to W_MED

10.16 Starts With

props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').startsWith('prefix')

props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').startsWith('W')

EG: Word starts with W (Condition satisfies then returns true or else returns false).

10.17 Ends with

props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').endsWith('suffix')

props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').endsWith('r')

EG: Colour ends with r (Condition satisfies then returns true or else returns false)

38
MVEL Expression Language

10.18 Clear and remove

props['ap.worker.past.map'].clear()

props['p.ee.hash.map'].remove(props['p.employee.id'])

10.19 Append
props['ap.page.worker.wids.sb'] = new java.lang.StringBuilder()

props['ap.page.worker.wids.sb'].append(props['p.employee.id']+', has a custom ID and will update with:,


'+props['p.file.custom.id']+'\r\n')

if(props['worker.hired.exists']==false){props['ap.page.worker.wids.sb'].append(props['current.worker.wid']).append(',') }

39
MVEL Expression Language

11 Control Flow: MVEL Expression Capabale Property:

11.1 if

Syntax: if(props['row.employee.id'] != props['last.employee.id']){/*do something here*/}

if(props['row.employee.id'] != props['last.employee.id']) { props['worker.offcycle.priority.out']


= 0; props['last.employee.id'] = props['row.employee.id']; }

11.2 If else

Syntax: if(props['p.is.boolean']){/*do something here*/}else]){/*do something here*/}

if(props['row.employee.id']!=props['last.employee.id']){props['worker.offcycle.priority.out']=0;}
else{props['worker.offcycle.priority.out']=empty;}

11.3 else if

Syntax:if(props['p.is.boolean']){/*dosomethinghere*/}elseif(props['row.employee.id']==props['last.employee.id']) {/*do
something here*/}else{/*do something here*/}

if(props['row.employee.id']!=props['last.employee.id'])
{ props['worker.offcycle.priority.out']=0;}elseif(props['row.employee.id']==props['last.employee.id'])
{props['worker.offcycle.priority.out']=1;}else{props['worker.offcycle.priority.out']=empty;}

40
MVEL Expression Language

41
MVEL Expression Language

12 Ternary Operator:

12.1 Ternary statements:

Ternary statement is similar to if else statement.

Syntax: props['worker_status'] = props['create_acct'] == 1 ? "Active" : "Inactive"

If props['create_acct'] == 1 then props['worker_status'] is Active otherwise Inactive

props['create_acct'] = props['report_acctid'] == '' ? true : false

props['worker_type'] = props['employee_Count'] == 1 ? 'Employee' : 'Contingent'

12.2 Nested Ternary Statements:

props['emp.row.count'] = props['count'] > 0 ? "Employee" : (props['count'] == 1 ? "Contingent" : "Worker")

if props['count'] > 0 it returns Employee otherwise it will check whether props['count'] == 1 returns Contingent
Otherwise returns Worker

42
MVEL Expression Language

43
MVEL Expression Language

13 Hash Map and Array list

13.1 Hash Map

Before Webservice or rass call and splitter:

props['p.ee.hash.map'] = new java.util.HashMap()

After Splitter put hashmap values

props['p.hash.key.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")

props['p.ee.hash.map'].put(props['p.hash.key.value'], parts[0].text)

After splitter Compare Input File with rass or websrvice call and get employee id:

props['p.employee.id']=parts[0].xpath("record/EmployeeID")

vars['p.ee.node']=props['p.ee.hash.map'].get(props['p.employee.id'])

if employee is found get custom id which is put along with employee id in hashmap

props['p.current.custom.id'] =if(vars['p.ee.node']!=empty){vars['p.ee.node'].xpath("wd:Report_Entry/wd:Custom_ID");}

13.2 Array List to Hash Map

Use this logic to convert an array into a single HashMap. In this example, we are just
checking that a value exists in the HashMap. A common use case is you only want to
process employees who are in a certain organization defined by an integration multi-
value attribute. If the Map returns a '1' value, this translates to a the get() being
successful

MVEL Expression Capabale Property:

44
MVEL Expression Language

1) Declare your HashMap

props['p.myHashMap']= new java.util.HashMap()

2) Get your Array list. In this case, it's a multi-value integration attribute

props['p.myAttributeList'] = intsys.getAttributeReferenceDataList('AttributeName', 'RefIDType')

3) Get the size of the Array list

props['p.myAttributesList.count'] = props['p.myAttributeList'].size()

4) Loop through the Array for each p.myAttributesList.count and put the list values in the HashMap

foreach(x : props['p.myAttributesList.count']){props['p.myHashMap'].put(props['p.myAttributeList'].get(x-1),'1')}

13.3 List to For Loop

Note:If we add or put our data to list or array list then only we can use for loop or for-
each statement in mvel expressions.

After Splitter and before aggregator:

list = context.getProperty('list');

props['id']=parts[0].xpath('/Put_Payroll_Off-cycle_Payment_Request/Payroll_Off-cycle_Payment_Data/Payment_ID')

list.add(props['id']); context.setProperty('list',list);

After aggregator

list = context.getProperty('list');

foreach(item:list) {System.out.println( item + ",")}

45
MVEL Expression Language

Another method for for loop

props['excluded-dce'] = false

int counter = props['excluded-dce-envs'].size()

foreach (x:counter) {if (props['dce-id'] == props['excluded-dce-envs'].get( x-1 )) {props['excluded-dce'] = true; }}

13.4 Remove Duplicates Using Array List

Before Webservice or rass call and splitter:

props['p.my.array.list'] = new java.util.ArrayList()

After Splitter put array list values

props['p.my.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")

if(!props['p.my.array.list'].contains(props['p.my.value'])) {props['p.my.array.list'].add(props['p.my.value']); }

13.5 Add and Contains Combination in Array List


props['p.array.list'] = new java.util.ArrayList()

props['p.array.list'].add(/*your directory key*/)

When you need to check if the data exists, you can do the following which returns a boolean:

props['p.array.list'].contains(/*directory key from file*/)

46
MVEL Expression Language

13.6 CleanUp or remove Hash Map

Before Webservice or rass call and splitter:

props['p.ee.hash.map'] = new java.util.HashMap()

After Splitter put hashmap values

props['p.hash.key.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")

props['p.ee.hash.map'].put(props['p.hash.key.value'], parts[0].text)

Before Webservice or rass call and splitter:

props['p.remaining.keys'] = props['p.ee.hash.map'].keySet()

After Splitter get hashmap values

props['p.employee.id']=parts[0].xpath("record/EmployeeID")

vars['p.ee.node']=props['p.ee.hash.map'].get(props['p.employee.id'])
47
props['p.ee.hash.map'].remove(props['p.employee.id'])
MVEL Expression Language

48
MVEL Expression Language

14 MVEL Template Capabale Property on webservice

14.1 Foreach-Statement Example on webservice

For Loop on xml message or webservice message on write component


To loop through an array or list you can use the following where
props['p.remaining.keys'] is a list value
Note:If we add or put our data to list or array list then only we can use for loop or for-
each statement in mvel expressions.

MVEL Template Capabale Property:


<root>
@foreach{props['p.remaining.keys'] as id}
<ee>@{id}</ee>
@end{}
</root>

14.2 If-Statement Example on webservice

MVEL Template Capabale Property:


If condition on xml message or webservice message on write component
<root>
@if{props['p.is.boolean']}
<ee>*Do Something Here*</ee>
@end{}
</root>

If statement Example on webservice

<wd:Workday_Account_for_Worker_Update
xmlns:wd="urn:com.workday/bsvc"
wd:version="v21.1">
<wd:Worker_Reference>
@{props['employee_id_string']}
</wd:Worker_Reference>
<wd:Workday_Account_for_Worker_Data>
@if{(props['worker_status'] == 'Inactive' && props['company_reference_id'] == 'MNA' &&
props['ia_allow_inactive_accounts'] == true) || (props['worker_status'] == 'Active' && props['company_reference_id'] ==
'MNA') || (props['worker_status'] == 'Inactive' && props['ia_allow_inactive_accounts'] == true)}
<wd:Account_Disabled>true</wd:Account_Disabled>
@end{}
@if{props['worker_status'] == 'Active' && props['company_reference_id'] != 'MNA'}
<wd:Account_Disabled>false</wd:Account_Disabled>
@end{}
</wd:Worker_Reference>
</wd:Workday_Account_for_Worker_Update> 49
</env:Body>
</env:Envelope>
MVEL Expression Language

15 Before and After Splitter

15.1 Last Row or Employee in Batch

How to find Last Employee in a batch after Splitter


props['last.row.to.process'] = util.isLastMessageInBatch()

15.2 To find total employees from input file


Initialize variable before splitter:

props['total.count'] =0

After Splitter

props['total.count'] = props['total.count'] + 1

or another method to find total employees from input file

props['total.count']=parts[0].xpath("count(/Worker_Tax_Election/State_Tax_Election)")

15.3 To find Success count on employee incase of inbound

Initialize variable before splitter:

props['prop.success.count']=0

After Loading data to webservice

props['prop.success.count'] = props['prop.success.count'] + 1

15.4 To find Error Count on employee incase of inbound


Initialize variable before splitter:

props['prop.error.count'] =0

After handling send error component where we use our webservice request

props['prop.error.count'] = props['prop.error.count'] + 1

or another method to find error employees


50
props['prop.error.count'] = props['total.count'] - props['prop.success.count']
MVEL Expression Language

15.5 Local-out condition Execute when

props['prop.percentage.change'] == true

15.6 In put message

props['prop.current.percentage']+'% complete.'

51
MVEL Expression Language

16 Studio Specific MVEL Expression Table

Va
ria Description Usage examples
ble
c Provides access to the The following expression gets the value of the
o MediationContext object, property myProperty on the MediationContext:
n which is the main context
t object used to pass context.getProperty('myProperty')
e information around in
assemblies. This class
x
contains various objects
t used to store and pass
the data between the
assembly components,
including:

 MediationMessag
e

 variables

 properties

 error and error-


related flags

 assembly audit

 customer id

 dynamic endpoint

d Within a Workday Studio The following example gets a document from


a integration, you can use the Integration Event with filename
the Document Accessor eib_transform_output.txt and adds is as
(da) variable within an a variable named var1:
eval step's MVEL

52
MVEL Expression Language

Va
ria Description Usage examples
ble

expression to access a da.toVar('eib_transform_output.txt',


document. 'var1')

e Provides access to the The following example returns the cc.hostname


n JVM system properties. environment property set as -Dcc.hostname
v on the command line:

env['cc.hostname']

e Provides access to the The following MVEL expressions return various


p wd.external.paygroupsMe results from calls to the
g diationContext property, Get_External_Paygroups Web service:
which contains the result
of a call to the  epg.isSet() == true
Get_External_Paygro
ups Web service  epg.getExternalPayGroups('descr
operation. The epg iptor')
variable is only applicable
to Workday internal  epg.getExternalPayGroupWID('des
server and integration criptor')
Cloud developers.
 epg.getStartDate('periodWid')

 epg.getStartDate('payGroupWid,
'periodWid')

 epg.getEndDate('periodWid')

 epg.getEndDate('payGroupWid,
'periodWid')

 epg.getPaymentDate('periodWid')

 epg.getPaymentDate('payGroupWid
', 'periodWid')

53
MVEL Expression Language

Va
ria Description Usage examples
ble
 epg.getWIDForStartDate('date')

 epg.getWIDForStartDate('payGrou
pWid', 'date')

 epg.getWIDForEndDate('date')

 epg.getWIDForEndDate('payGroupW
id', 'date')

 epg.getWIDForPaymentDate('date'
)

 epg.getWIDForPaymentDate('payGr
oupWid', 'date')

 epg.getCurrentPeriod('date')

 epg.getCurrentPeriod('payGroupW
id', 'date')

 epg.getPreviousPeriod('date')

 epg.getPreviousPeriod('payGroup
Wid', 'date')

 epg.getNextPeriodReference()

 epg.getNextPeriodReference('pay
GroupWid')

f Returns the result of an The following MVEL expressions return true:


t ftp list operation. The ftp
p variable is bound to an  ftp.isSftp('sftp://
instance of the myserver.somewhere.com/
MVELFTPHelper utility myDirectory')
class. It can be used to

54
MVEL Expression Language

Va
ria Description Usage examples
ble

test URI protocol  ftp.isExplicitSSL('ftpse:/


schemes used to myserver.somewhere.com/
represent FTP, SFTP, myDirectory')
FTPS, FTPSE (FTPS with
explicit mode SSL), and
FTPSI (FTPS with implicit
mode SSL).

Currently the Workday


Network only supports
FTPS with implicit mode.

i Provides access to the The following expression accesses an


n integration system integration attribute named username:
t configuration for this
s assembly. intsys.getAttribute('username')
y
Note: The workday-in
s
transport calls the
Get_Integration_Sys
tems Web service
operation transparently to
get integration attribute
and map settings and
populates the wd.int.sys
property using the
intsys MVEL variable. If
you use intsys
convenience methods
such as intsys.name,
which returns the
integration system name,
you must first define
services on the
workday-in that define
attributes and maps for
the integration system.
Using intsys to access

55
MVEL Expression Language

Va
ria Description Usage examples
ble

an attribute at runtime will


causes a failure unless a
service is defined on the
integration system. For
more details, see
“Defining and Configuring
the Attribute Map Service
for an Integration”.

l Provides access to the The following MVEL expressions return various


p integration launch results from the
parameters. The lp Launch_Integration_Event_Data Web
variable is only applicable service operation, where the label value is the
to Workday internal wd:Parameter_Name value or its wd:Label
server and integration value:
Cloud developers. The
implementation class for  lp.getUserName()
this variable is:
 lp.getUserNameWID()
com.workday.integrati
on.launch.LaunchPara  lp.getIntegrationEventWID()
metersHelper
 lp.getIntegrationSystemRefWID()
Before using the lp
MVEL variable, you need  lp.isSet() == true, which is true if
to assign the launch the wd.launchparameters property
parameters XML to the contains an XML document in the correct
variable called format.
wd.launchparameters
. When an integration  lp.getParameterData('label'),
receives its launch which returns the
parameters from the OMS Integration_Runtime_Parameter_
in the form of the Data element for the given parameter.
wd:Launch_Integrati
on_Event_Data  lp.exists('label') == true, which
element, it can assign the is true if a parameter with the given label
XML context to the

56
MVEL Expression Language

Va
ria Description Usage examples
ble

exists.
wd.launchparameters
variable. An integration  lp.getSimpleData('label'), which
can also construct the only applies to parameters of simple
wd:Launch_Integrati type, such as string, date, or number.
on_Event_Data XML
message in the case of  lp.getDate('label'), which returns
an externally launched an xsd:date value as a string. This
integration such as only applies to parameters of simple
Payforce. type, such as string, date, or number.
Time portions are excluded if the
underlying data value includes them.

 lp.getMap('label'), which is used for


parameters that have multiple values
with Instance_Set_Reference
elements. The properties object contains
all the IDs for each instance.

 lp.getWIDs('label'), which is used


for parameters that have multiple values
with Instance_Set_Reference
elements.

 lp.getDescriptor('label',
'wid'), which is used for parameters
that have multiple values with
Instance_Set_Reference elements.
It returns the wd:Descriptor attribute
associated with the instance with the
given WID.

m Provides access to the The following expression gets the root part of
e MediationMessage the message as text from the
s interface. MediationMessage interface:
s

57
MVEL Expression Language

Va
ria Description Usage examples
ble
a message.rootPartAsText
g
e

m Provides access to the The following expression sets data in an


t MTableAdapter interface, MTable:
a which defines the
b operations on an MTable mtable['my_property'].set(0,
l instance, where MTable is 'Data_Column', 'my_test_data')
an in-memory table of
e
data. The following expression gets data from an
MTable:

mtable['my_property'].get(0,
'Data_Column')

p Provides array-based For example, to get the content of part 0, the


a access to message parts root part:
r using the
t MessageAdapter parts[0].text
s interface. The root part is
part 0, the first To get the content of the first attachment:
attachment is part 1.
parts[1].text

To get the header someHeader from the root


part:

parts[0].getHeader('someHeader')

To get the MIME type of the root part:

parts[0].mimeType

To get the content of the root part as a


DOMSource:

58
MVEL Expression Language

Va
ria Description Usage examples
ble

parts[0].getAs(DOMSource)

To get the content of the root part as a String:

parts[0].getAs(String)

To get the string content of the XPath


expression /a/b:

parts[0].xpath('/a/b')

or the equivalent with namespace overrides:

parts[0].xpath('/xx:a/xx:b', 'xx
http://www.somewhere.com')

Note: By default, the Workday server runtime


takes all XML prefix-to-namespace mappings
for XPath expressions from the assembly.xml
file, inspecting all of the XML elements in the
file. Specify namespaces within the xpath
method only to override the declarations in the
file. This default behavior applies to MVEL
expressions that use the MessageAdapter
interface only.

To evaluate an XPath Boolean expression, you


use the xpathB method.

parts[0].xpathB('/a/b')

This evaluates whether the node /a/b exists in


the document. This method is also overloaded
to support a second namespace parameter.

The xpathF method returns the result of the


XPath query as a string containing the XML

59
MVEL Expression Language

Va
ria Description Usage examples
ble

fragment representing the node list of the


results. An empty string is returned if the XPath
expression does not produce any matches.

parts[0].xpathF('/a/b')

This method is also overloaded to support a


second namespace parameter.

You can also use set accessors for text,


headers, and MIME types, for example:

parts[0].setText('Here is some new


content')
parts[0].setMimeType('text/xml')
parts[0].setAs('Here is some new
content')

parts[0].setHeader('SomeHeader',
'SomeValue');

p A utility adapter for The following expression is equivalent to


r gaining access to
o message properties using context.getProperty('myProperty')
p the
AssemblyUtils.Prope but less verbose:
s
rtyMapAdapter class.
See the warning message props.myProperty
below this table for
property name issues. The following expression returns the property
value set by a custom Spring bean:

props['bean.property']

s Provides access to the The following expression gets the name


p Spring context for the attribute of the bean called Fred in the Spring

60
MVEL Expression Language

Va
ria Description Usage examples
ble
r WSAR using the context:
i ApplicationContext
n interface. spring.getBean('fred').name
g

u Provides access to You can use the following expression in


t utilities for working with conjunction with the splitter component to
i MVEL expressions. The check whether the current message in the
l util variable is bound to MediationContext is the last message that
an instance of the the splitter will generate:
MVELUtilHelper utility
class, which provides props['is.last.record'] =
handy functions for use util.isLastMessageInBatch()
within MVEL expressions
such as time and date To ensure that an assembly component
manipulation and XML produces well-formed XML, use the
testing. Workday currently cleanString(String) function, for
provides over 40 utility example, within a write step's text element,:
functions that you can
access using the util &lt;ns:Message_Summary>@{util.cleanSt
variable. For more details, ring(props['is.message.summary'])}&lt;/
see the Javadoc for each ns:Message_Summary>
utility function.

v Provides access to the For example, to get the text of the variable
a MessageContextVariabl myVariable:
r es interface as a Map. To
s access variables, use the vars['myVariable'].text
following notation:
To determine if a variable is defined:
vars['myVariable']
vars['myVariable'] != null

To get the MIME type associated with a


variable:

vars['myVariable'].mimeType

61
MVEL Expression Language

Va
ria Description Usage examples
ble

To get the string value of node /a/b using


XPath:

vars['myVariable'].xpath('/a/b')

or the equivalent with namespace support:

vars['myVariable'].xpath('/xx:a/xx:b', 'xx
http://www.somewhere.com')

To evaluate an XPath Boolean expression, you


use the xpathB method:

vars['myVariable'].xpathB('/a/b')

This evaluates whether the node /a/b exists in


the document. This method is also overloaded
to support a second namespace parameter:

vars['myVariable'].xpathF('/a/b')

This returns a string containing the XML


fragment for a node-list that matches /a/b zero
or more times. This method is also overloaded
to support a second namespace parameter.

x Returns the result of the The following expression checks whether there
m xmldiff step as a Java are differences between the two documents:
l object of type
d xmldiff.isDifferent() == true
XMLDiffStepResult,
i which is also available as For more examples of the xmldiff MVEL
f a property called variable usage, see “Sample MVEL Usage”.
f wd.xmldiff.step.result in
the MediationContext.

62
MVEL Expression Language

For Loop in mvel:

props['Workers']=lp.getReferenceDataList( 'mySelectedWorkers', 'Employee_ID')

<?xml version="1.0" encoding="UTF-8"?>

<wd:Get_Workers_Request xmlns:wd="urn:com.workday/bsvc" wd:version="v22.1">

<wd:Request_References wd:Skip_Non_Existing_Instances="true">

@foreach{props['Workers'] as emp}

<wd:Worker_Reference>

<wd:ID wd:type="Employee_ID">@{emp}</wd:ID>

</wd:Worker_Reference>

@end{}

</wd:Request_References>

</wd:Get_Workers_Request>

If condition for webservice in wstester

<root>

@if{props['p.is.boolean']}

<ee>*Do Something Here*</ee>

@elseif{props['p.numeric.value'] == 1}

63
MVEL Expression Language

<ee>*Do Something Else*</ee>

@else{}

<ee>*Else*</ee>

@end{}

</root>

64
MVEL Expression Language

17 USEFUL Links:

http://mvel.codehaus.org/Home

http://www.mulesoft.org/documentation/display/current/Mule+Fundamentals

http://mulesoft.github.io/mule-module-mvel/usage.html#mvel-fundamentals

http://www.w3schools.com/xpath/xpath_nodes.asp

65

You might also like