Feature update – .lowercase, .uppercase, .round a number, find the .minimum and .maximum value in a collection of numbers and more!

Here’s what’s new:

Text editing


We identified some common operations with text variables and we have created methods so that you can use them in a pinch! Here is how they work:

UPPERCASE and LOWERCASE
You can easily make a text variable all uppercase or lowercase with these new methods:


CLEAN
This method removes the spaces and any other “whitespace” or blanks such as tabs, carriage return characters or newline characters at the beginning and the end of a text variable:

In this example, the value of cleanSongLyrics is “ta da daaaa“. Note that the spaces in between words remain!

URL ENCODING
Replace unsafe ASCII characters with a “%” followed by two hexadecimal digits to create valid URLs using the method encode with the parameter “URL”. 


Here the value of encodedURL is http://www.cityinfo.com?city=Gen%C3%A8ve&planet=The%20Earth“.

Use the method decode(“URL”)  to undo a previous ‘URL encoding’, replacing the ‘%’-based ‘escape sequence’ of characters with their normal representation.

SPLIT
With split you can turn a text variable into a collection, by selecting a delimiter that you will use to split the variable.

In this example, collectionOfFruits is [“pears”,” bananas”,” oranges”,” mangoes”]. Notice that there is a space before the words bananas, oranges and mangoes! If you want to get rid of it, use the “clean” method.

The delimiter can have more than one character:

Here collectionOfFruits becomes [“pears”,”bananas”,”oranges”,”mangoes”].

Round numbers

Use the round method to round numbers to the nearest integer or to set the number of decimals to display:

In the example above, the value of piInteger would be 3, piTwoDecimals, 3.14 and piFourDecimals, 3.1416

New methods to work with collections

MAXIMUM, MINIMUM AND MEDIAN VALUE
If you are working with a collection of numbers, you can easily retrieve the maximum or minimum value in the collection as well as the median:

UNIQUE VALUES IN A COLLECTION
Use the unique method to get rid of duplicates in a collection:

Here citiesVisited becomes [“Amsterdam”, “Madrid”, “London”, “Rome”, “Lisbon”].

Check if a value is in the keys of an association

If you need to check if a certain value is in the keys of an association, you can now use the expresion in – the same way as with collections.

Imagine you have an association with people’s phone numbers. You have a user whose name is stored in the variable userName, and you want to ask them for their number only if you don’t have it already:

The result of evaluating the expression (something in association) has two possible values: “TRUE” or “FALSE”.

Chaining methods

If you want to apply a method to the result of another method, you can do it in the same line of code!

In the example above, the method encode(“URL”) will be applied to the variable urlToEncode and the resulting string will then be made uppercase. The value of encodedUppercaseURL is then “http://WWW.CITYINFO.COM?CITY=GEN%C3%A8VE&PLANET=THE%20EARTH”

This other example calculates the median value of a collection of numbers and rounds it to the closest integer:

*service updates

When you are making GET requests, now you can pass query parameters using *send instead of adding them to the path. This is especially useful to send special characters without having to URL-encode them.

In this example, the code below will FAIL because of the è in Genève:

You can send the parameters creating an association with them, where the key is the name of the parameter and the value is the value you want to send, and using the attribute *send:

Also, *service has been updated and now accepts PATCH requests. You can find a detailed case study of using PATCH to update records in Airtable in the manual. Otherwise, check out the documentation of the API service to configure the parameters of your patch request.