Custom Sub Functions are a good way to keep your transforms maintainable and easy to read by creating a library of custom components with reusable functionality.
Liquid Data Mapper - Sub Functions |
In this example we want to tidy up our customers first name and last name, by capitalizing the first letter. The transform to do this is fairly easy to follow, it takes the first letter and makes it upper case, it takes everything after the first letter and makes it lower case and concatenates the 2 bits back together.
Although its simple there are a few parts to it and we need to use it more than once, so it ends up making our transform look quite complex.
The solution is to create a Sub Function.
Sub Function Sample - CapitalizeFirstLetter
Liquid Data Mapper - Sub Functions |
The name and type of the sub functions inputs and outputs can be configured. You can also add more inputs and outputs as required.
It is important to name the sub function. This can be done by clicking on the canvas and setting the ‘Name’ Property in the properties window. This is the name that will then be used to find the sub function.
Sub functions can also make use of other sub functions.
Liquid Data Mapper - Sub Functions |
Tip: Execute the transform by pressing Shift-F5. Debug the transform by pressing F5 to start the debugger, then:
F11 - Step Into
F9 - Set break point
F5 - Run (stops on break points)
A free trial of the Liquid Data Mapper is available from:
https://www.liquid-technologies.com/trial-download