Functions

Updated 1 week ago by Karan

In this step-by-step guide, you will understand how to use functions for optimizing the data in the required format.

Configuring functions

The functions are used to convert data format in various task nodes of a Byteline flow. By default, all data is sent as a string, but the functions can be used to send the data in the appropriate format. For example, if the Airtable column is configured as a number, it should be sent in that format only.

Let's configure functions to convert the data format.

Step 1: Click on the selector tool to select the functions for converting data format.

Step 2: Click on the function button to view all the functions.

Step 3: You can select any of the functions you want to use from the functions pop-up.

There are the following functions:

Datetime

Select the DateTime function to convert the input data to DateTime format. It takes the date in the different formats e.g. epoch number and produces a date string in the yyyy-MM-dd'T'HH:mm:ss.SSS format.

Number

Select the number function to convert the input data to a numerical format. The Numeric values can be Integer, float, decimal, etc.

Bool

Select the bool function to convert the input data to a boolean format. In boolean format, data can have two possible values either true or false.

Today

Select today function to generate today's date in the MM/dd/yyyy format.

Replace

Select replace function to replace any regular expression.

  1. Enter the text to be replaced in the search for field.
  2. Enter the replacement text in the replacement field.
  3. Select either yes or no option from the is regex dropdown menu to confirm whether the replacement text is a regular expression or not.
  4. Click on the Save button to save the function configuration.
Array

Select array function to convert a comma-separated string into an array. The data is represented as type[], where type is the data type of the contained elements and brackets represent the array.

Maxlength

Select maxlenght function is used when the user wants to keep the first n characters from a string. You can also pass an integer value as an argument.

  1. Enter the maxlenght of strings you want in the limit field.
  2. Click on the Save button to save the maxlenght configuration.

Sha1

Select the Sha1 function to convert a string to the hash value. Sha1 is used to calculate an alphanumeric string, serving as a cryptographic representation of data. The SHA-1 function is used to carry out Hex and Base64 encoding.

  1. Select the encryption option from the encoding dropdown menu.

There are the following encoding options:

  • Hex - Hex encoding is performed to convert 8-bit data to 2 hex characters.
  • Base64 - Base64 encoding is performed to convert binary data to an ASCII text format, and vice versa.
  1. If you have performed HMAC SHA1 then you need to enter the decryption key value in the key field.
  2. Click on the Save button to save the SHA1 configuration.
Image

Select image function to convert image URL to the required format e.g. Airtable.

MarkdownToHtml

Select markdownToHtml function to convert Markdown text to HTML.

ElementAt

Select elementAt function to fetch an element from an array. You can specify an index to get the particular element, 0 is used to indicate the first element index.

  1. Enter the index in the index field to fetch the particular element.
  2. Click on the Save button to save the elementAt configuration.
String

Select the string function to convert an input value to a string.

jq

Click on the jq function to execute the JQ expression on the input data. This helps to convert or extract data from the input JSON data.

  1. Enter the JSON data you want to convert in the expression field.
  2. Click on the Save button to save the jq configuration.

Thus you can use functions in your nodes to set them into the right format. Feel free to connect us for any doubt.


How did we do?