Functional and dot notation and function chaining

You must use proper syntax when adding transform functions to your script, or your script won't run properly. You can reference all transform functions using functional notation, as described in this topic.

<function>(<argument1>[,<argumentN>])
For example, the following code applies the geotagAddress function to an attribute called address:
geotagAddress(address)
You can use dot notation to include original Groovy functions that aren't specific to Studio:
<attribute>.<function>()
For example, the following code uses the toString function to convert an attribute called quantity to a String:
quantity.toString()

Note:

You can only use dot notation for original Groovy functions. For the BDD-specific transform functions, you must use functional notation.

Function chaining

Function chaining allows you to apply multiple functions to an attribute in a single statement. You chain functions by passing an attribute to one function, then passing that function to another function. The innermost function (the one receiving the attribute as a parameter) is evaluated first, and the outermost function is evaluated last.

For example, the following code takes an IP address, determines the city it originated from, then converts the name of the city to uppercase:
// Performs two transformations on a single attribute using one line of code:

toUpperCase(geotagIPAddressGetCity(IP_address))
The following code produces the same result as the code above, but is more verbose:
// The same two transformations as above, without chaining.
// 'city_name' is a temporary variable that stores the output of geotagIPAddressGetCity()

def city_name = geotagIPAddressGetCity(IP_address)
toUpperCase(city_name)

As you can see in the examples, function chaining makes your code cleaner and easier to read. Additionally, not having to include placeholder variables, such as city_name in the second example, helps make your code less error prone.