Module 2
Data Mapping & Transformation
Workato University
Intermediate Course
After completing this session, you’ll be able to
● Know data mapping
● Use basic formulas
● Use formulas to build recipe
Integrate. Automate. Innovate Proprietary and Confidential 2
Agenda for Module 2 (Data Transformation)
1. Data mapping
2. Overview of formulas
3. Different types of basic formulas
4. Data format and type conversion formulas
Integrate. Automate. Innovate Proprietary and Confidential 3
Data Mapping
Workato University
Working with Data in Recipes
1. By default, Workato’s smart connectors
introspect the data schema in connected
app/system and pull the standard &
custom objects as well as standard &
custom fields available for data mapping
2. Some connectors have a “Fields” input
① to allow you to limit the output fields
②
3. If the app schema changes (e.g. new
custom field), click on the “schema
refresh” button at the bottom of the
recipe page to fetch the latest data
②
schema
Integrate. Automate. Innovate © Copyright 2019 Workato Inc. All rights reserved 5
Data Mapping: Data Tree
● Output data from trigger or action
step
● Contained within data trees, within
App Data section
○ Contains output from trigger
and every action preceding this
step
Integrate. Automate. Innovate Proprietary and Confidential 6
Data Mapping: Data Types
● Data can be of different types, such as:
○ Text/String
○ Integer
○ Float
○ Object
○ Date
○ Date-Time
○ Boolean
○ Array/List
Data types inform about the Sample data: Shows
type and formula applicability on what kind of data the
a data value data pill stores
Integrate. Automate. Innovate © Copyright 2019 Workato Inc. All rights reserved 7
Data Mapping: Map Data Pills from Right to Left
App data:
Data pills are
Data fields: Fields and presented in a data
picklist associated tree on the right. An
with the app and output data tree is
object that you are generated for each
working with. step in the recipe.
Integrate. Automate. Innovate © Copyright 2019 Workato Inc. All rights reserved 8
Data Mapping: Mapping of Input Fields
Static/Constants:
Dynamic/Variables:
Combination:
Formula:
Integrate. Automate. Innovate © Copyright 2019 Workato Inc. All rights reserved 9
Data Transformation
Workato University
Formula Mode
● Switch between Text/Formula mode
at field level
● Use period “.” to see formula options
● Formulas are recommended based
on the data pill type
● Explanation of formula function as
well as syntax will be provided
● Formulas are whitelisted ruby
methods
Integrate. Automate. Innovate © Copyright 2019 Workato Inc. All rights reserved 11
Common Formula Examples
Formulas can be combined:
If-Else Conditions:
Handle blank input:
Find and replace:
Integrate. Automate. Innovate Proprietary and Confidential 12
Common Formula Examples
Date operations:
Retrieve values by field name:
Perform math on lists:
Convert strings to lists:
As just a few examples...
Integrate. Automate. Innovate Proprietary and Confidential 13
Formulas: Whitelisted Ruby Methods
binary? is_not_true? to_country_alpha3 upcase abs max
blank? is_true? to_country_name workato.jwt_encode_rs256 ago min
capitalize length to_currency workato.parse_yaml as_string odd?
decode_base64 ljust to_currency_code workato.render_yaml as_utf8 pluck
decode_hex lstrip to_currency_name All other formulas beginning_of_day round
decode_urlsafe_base64 match? to_country_name % beginning_of_hour smart_join
downcase md5_hexdigest to_currency * beginning_of_month strftime
encode parameterize to_currency_code ** beginning_of_week sum
encode_base64 presence to_currency_name + beginning_of_year to_csv
encode_hex present? to_currency_symbol - dst? to_json
encode_sha256 reverse to_date / encode_www_form to_xml
encode_url rjust to_f clear end_of_month uniq
encode_urlsafe_base64 rstrip to_hex decrypt even? utc
ends_with? scan to_i encrypt except wday
exclude? slice to_param lookup first where
gsub split to_phone lookup_table flatten yday
hmac_md5 starts_with? to_s now format_map yweek
hmac_sha1 strip to_state_code null from_now
hmac_sha256 strip_tags to_state_name skip in_time_zone
hmac_sha512 titleize to_time today join
include? to_country_alpha2 transliterate uuid last
https://docs.workato.com/formulas.html#formulas
Integrate. Automate. Innovate Proprietary and Confidential 14
String Formulas
Workato University
Common String Formulas
Formula Function Example Result
" ".present? false
"nil".present? false
.present? Check the input for value
"Jean Marie".present? true
"Jean Marie".include?("Jean") true
Check if input string "Jean Marie".include?("ma") false
.match?(“text”) value matches the text
exactly, case sensitive
"Jean
Marie".downcase.include?("ma")
true
Integrate. Automate. Innovate Proprietary and Confidential 16
Common String Formulas
Formula Function Example Result
"Jean Marie".include?("Jean") true
Check if the input string "Jean Marie".include?("ma") false
.include?(“text”) for any part of the field
value includes the text
"Jean
Marie".downcase.include?("ma")
true
"Jean
Marie".starts_with?("Jean")
true
"Jean
Check if the input string false
Marie".starts_with?("jean")
.starts_with?(“text”) for the field value starts
with the text
"Jean
Marie".upcase.starts_with?("JEA true
N")
Integrate. Automate. Innovate Proprietary and Confidential 17
Common String Formulas
Formula Function Example Result
Replaces all special "Jeân Mârie".parameterize "Jean Marie"
.parameterize
characters in a string
Replaces non-ASCII
.transliterate characters with ASCII
approximation
Remove whitespace at the " Jean Marie ".strip "Jean Marie"
.strip
start and end of the string
Remove whitespace at " Jean Marie ".lstrip "Jean Marie "
.lstrip
beginning of the string
Remove whitespace at the " Jean Marie ".rstrip " Jean Marie"
.rstrip
end of the string
Integrate. Automate. Innovate Proprietary and Confidential 18
String Conditions: Slice
_______ .slice (_______ , _______)
Index of the Number of
Data pill character to characters
start with to return
1st character 2nd character ... (n-1)th character nth character
0 1 n-2 n-1
Integrate. Automate. Innovate Proprietary and Confidential 19
String Conditions: Slice
Address:
“Cupertino, CA 95014”
9 5 0 1 4
-5 -4 -3 -2 -1
“95014”
Integrate. Automate. Innovate Proprietary and Confidential 20
Number Formulas
Workato University
Arithmetic operations
● Important to know whether value is integer or float (decimal) type
● Formula will stick to the type given as input
● Returned result will be of the most precise type
● For example:
○ If input is integer value, output will be integer value
○ If both integer and float values are provided, float value will be returned as
it is more precise
Integrate. Automate. Innovate Proprietary and Confidential 22
Arithmetic Operations
Formula Function
Pill A + Pill B Addition
Pill A - Pill B Subtraction
Pill A * Pill B Multiplication
Pill A / Pill B Division
Pill A ** Pill B Exponent -- raise pill A to the power of pill B
Pill A % Pill B Modulo -- divide pill A by pill B and return the remainder
Integrate. Automate. Innovate Proprietary and Confidential 23
Round off
_______ .round(n)
Data pill
Hundreds Tens Ones Tenths Hundredths
-2 -1 0 1 2
Integrate. Automate. Innovate Proprietary and Confidential 24
Date Formulas
Workato University
Relative Dates
Date: (Year) - (Month) - (Day) Time: (Year) - (Month) - (Day) T (Hour) :
(Minute) : (Seconds) (UTC offset)
Formula Function Example Example Output Format
Return the current date now 2017-04-02T12:30:00.000000-07:
now
and time 00
today Return the current date today 2017-04-02
Adds the specified amount 3.days.from_now 2017-04-05T12:30:00.000000-07:
.from_now of time to the current date 3.minutes.from_now 00
and time
Subtracts the specified 3.days.ago 2017-04-05T12:30:00.000000-07:
.ago amount of time from the 3.minutes.ago 00
current date and time
Integrate. Automate. Innovate Proprietary and Confidential 26
Date Operations
Formula Function
+ Adds the specified amount of time to the specified date
- Subtracts the specified amount of time from the specified date
Integrate. Automate. Innovate Proprietary and Confidential 27
Beginning of Month/Year
_______ .beginning_of_month _______ .beginning_of_year
Data pill Data pill
Integrate. Automate. Innovate Proprietary and Confidential 28
Display Conversion
● .strftime formula
● To change the format of a
datetime value
Integrate. Automate. Innovate Proprietary and Confidential 29
Time Zone Conversion
_______ .in_time_zone(“______”)
Data pill Time zone to
convert to
Integrate. Automate. Innovate Proprietary and Confidential 30
Date/Time Conversion
Formula Function Example Example Output Format
"2017-04-02".to_date "2017-04-02"
Converts value in another
data type, e.g. date or
.to_date "2017-04-02T12:30:30.462659
string, into a date data "2017-04-02"
-07:00".to_date
type. Return YYYY-MM-DD
"2017-04-02T12:30:30.462659
"2017-04-02T19:30:30.462659+00:00"
Converts value in another -07:00".to_time
data type, e.g. date or
.to_time
string, into a date data
"2017-04-02".to_time "2017-04-02T00:00:00.000000+00:00"
type.
Integrate. Automate. Innovate Proprietary and Confidential 31
List Formulas
Workato University
Lists (Arrays)
● Arrays are ordered, integer-indexed collections of any object
● List indexing starts with 0
● It is the same as Ruby arrays
Integrate. Automate. Innovate Proprietary and Confidential 33
Retrieve Value by Position: Index
_______ [ ____ ]
Data pill Index
1st item 2nd item ... (n-1)th item nth item
0 1 n-2 n-1
-n -(n-1) -2 -1
Integrate. Automate. Innovate Proprietary and Confidential 34
Lists(Arrays)
● For example: number_list = [100, 101, 102, 103, 104]
● User can use the following formula to get the values or index
Example Result
Example Result
number_list.first 100
number_list[0] 100
number_list.second 101
number_list[1] 101
number_list.third 102
number_list[2] 102
number_list.fourth 103
number_list[3] 103
number_list.fifth 104
number_list[4] 104
number_list.last 104
Integrate. Automate. Innovate Proprietary and Confidential 35
Retrieve Value by Position
● For example: number_list = [100, 101, 102, 103, 104]
● Lists also support ranges as indexes, it will return another list
Example Result
number_list[0..2] [100, 101, 102]
number_list[-3..-1] [102, 103, 104]
Integrate. Automate. Innovate Proprietary and Confidential 36
Hashes
● Dictionary-like collection of unique keys and values
● Similar to Lists, but a List uses integers as its index, Hash allows user to use any
object type.
● Example:
line_item = { ‘item_name’ => ‘Acme widgets’, ‘item_qty’ => 10}
Example Result
line_item[“item_name”] “Acme widgets”
line-item[“item_qty”] 10
Integrate. Automate. Innovate Proprietary and Confidential 37
List of hashes
● Able to implement Lists and Hashes together
● Example:
line_items = [ # list
{ 'item_name' => 'Acme widgets' , 'item_qty' => 10 }, # hash 1
{ 'item_name' => 'RR bearings' , 'item_qty' => 100 }, # hash 2
{ 'item_name' => 'Coyote tyres' , 'item_qty' => 7 } # hash 3
]
Integrate. Automate. Innovate Proprietary and Confidential 38
List Formulas
● .where
○ Retrieves only rows that satisfy the specified WHERE condition
○ Accepts a single argument in the form of a hash with one or more key-value
pairs
○ Default operand for the condition is equal to (==)
Integrate. Automate. Innovate Proprietary and Confidential 39
Retrieve Value by Field Name
_____.pluck(‘_____’, ‘_____’)
Data pill Field Name/s
Integrate. Automate. Innovate Proprietary and Confidential 40
Lists Conditionals
Formula Function Example Result
["a", "b",
Return true if given true
"c"].include?("b")
object is present
.include?
["a", "b",
"c"].include?("z")
false
It will check the input, ["", nil].present? true
.present? return true if value
present " ".present? false
It will check the input, ["", nil].presence ["", nil]
return its value if there
.presence? is one present " ".presence
nil
Integrate. Automate. Innovate Proprietary and Confidential 41
Conditionally Execute Formulas: If-Else Condition
_______ ? ______ : ______
Conditional Value if Value if
True False
Integrate. Automate. Innovate Proprietary and Confidential 42
If-Else Condition Example
Address:
“Cupertino, CA 95014”
“Cupertino, CA 95014”
Integrate. Automate. Innovate Proprietary and Confidential 43
Conditionals: If-Else statements: Nesting
_______ ? (_______ ? ______ : ______) : ______
Conditional A Conditional B Value if Value if Value if
B is B is A is
True False False
Value if A is True
Integrate. Automate. Innovate Proprietary and Confidential 44
Summary
Workato University
Summary
● Data Mapping
● Different Formulas Types
○ String
○ Number
○ Date
○ List
● If-else statement
Integrate. Automate. Innovate Proprietary and Confidential 46
Next Module: List Processing
Workato University