How would I modify the following MuleSoft Transform Message to reverse the concatenation of the EMPLOYEE_CODE field?
Background: I am working with a MuleSoft process that (i) queries data from a database using a 'SELECT' component (ii) then transforms it into a specified .csv format using a series of 'Transform Message' components and (iii) deposits the .csv onto a SFTP server.
One of the data fields (EMPLOYEE_CODE) has data that comes from the DB in this format: 01-1111 (two characters before a '-' and four characters after). I need my MuleSoft Transform message to swap the order of this separation in the EMPLOYEE_CODE field to output it in this format: 1111-01 (latter four characters now before the '-' and the initial two characters after the '-') before generating the .csv file.
Current MuleSoft Transform Message:
%dw 2.0
output application/csv
quoteValues=true
---
payload map {
employeeID: $.EMPL_ID,
firstName: $.FIRST_NAME,
lastName: $.LAST_NAME,
employeeCode: $.EMPLOYEE_CODE
}
For references, here's an example Data Table that I'm receiving from DB:
EMPL_ID | FIRST_NAME | LAST_NAME | EMPLOYEE_CODE |
---|---|---|---|
0000001 | John | Doe | 01-1111 |
0000002 | Rick | James | 02-2222 |
0000003 | John | Smith | 03-3333 |
Transform Message needs to change this to (1111-01, 2222-02, and 3333-03).
For reference, here's the SQL Query in my Select:
SELECT
EMPL_ID
FIRST_NAME
LAST_NAME
EMPLOYEE_CODE
FROM DATABASE.TABLE