Skip to main content

Helper Methods

HELPER methods can help with data manipulation and transformation operations. These methods can be used to manipulate or transform data in String, Array and Object formats.

TRANSFORMDATATOARRAY

HELPER.TRANSFORMDATATOARRAY() method can be used to transform an object to an array of objects. This method is useful when the data object has key-value pairs that represent the columns of a table.

Usage
HELPER.TRANSFORMDATATOARRAY(inputObject);
Example
HELPER.TRANSFORMDATATOARRAY({
id: [1, 2, 3],
name: ['Jack', 'James', 'John'],
location: ['New York', 'London', 'Sydney']
});
Result
[
{ id: 1, name: 'Jack', location: 'New york' },
{ id: 2, name: 'James', location: 'London' },
{ id: 3, name: 'John' , location: 'Sydney' }
]

TRANSFORMDATATOOBJECT

HELPER.TRANSFORMDATATOOBJECT() method can be used to transform an array to an object. This method is useful when the data is an array of objects where each object has same set of keys.

Usage
HELPER.TRANSFORMDATATOOBJECT(inputArray);
Example
HELPER.TRANSFORMDATATOOBJECT(
[
{ id: 1, name: 'Jack', location: 'New york' },
{ id: 2, name: 'James', location: 'London' },
{ id: 3, name: 'John' , location: 'Sydney' }
]
);
Result
{
id: [1, 2, 3],
name: ['Jack', 'James', 'John'],
location: ['New York', 'London', 'Sydney']
}

INTERCHANGE

HELPER.INTERCHANGE() method can be used to swap the position of two elements in an array.

Usage
HELPER.INTERCHANGE(inputArray,index1,index2);
Parameters
ParameterAcceptsPossible values
inputArrayarrayarray of elements
index1integerposition index of first element
index2integerposition index of second element
Example
HELPER.INTERCHANGE(["apple", "banana", "orange", "grape", "kiwi"],0,4);
Result
["kiwi", "banana", "orange", "grape", "apple"]

MERGEARRAYS

HELPER.MERGEARRAYS() method can be used to merge two arrays into one.

Usage
HELPER.MERGEARRAYS(array1,array2);
Example
HELPER.MERGEARRAYS(["apple", "banana", "orange"], ["grapes", "pineapple"]);
Result
["apple", "banana", "orange","grapes", "pineapple"]

CONCATENATE

HELPER.CONCATENATE() method can be used to merge two or more strings into one.

Usage
HELPER.CONCATENATE(string1,string2,string3);
Example
HELPER.CONCATENATE("hi ", "hello ", "How are you?");
Result
"hi hello How are you?"

FLATTEN

HELPER.FLATTEN() method can be used to convert a multi dimensional array into a single dimension array.

Usage
HELPER.FLATTEN([array1,array2,array3]);
Example
HELPER.FLATTEN([1, [2, 3], [[4, 5], 6], [7, 8, [9, 10]]]);
Result
[1,2,3,4,5,6,7,8,9,10]

RANGE

HELPER.RANGE() method can be used to create an array of numbers for a specified range.

Usage
HELPER.RANGE(start,end);
Example
HELPER.RANGE(5,10);
Result
[5,6,7,8,9,10]

GETKEYVALUE

HELPER.GETKEYVALUE() method can be used to get value of a specified key from object.

Usage
HELPER.GETKEYVALUE(object,key);
Example
HELPER.GETKEYVALUE(
{
"key1": "DRONA",
"key2": "HQ",
"key3": "WELCOMES",
"key4": "YOU"
},"key1");

Result
DRONA

ARRAYTOCSV

HELPER.ARRAYTOCSV() method can be used to convert an array of arrays into csv format.

Usage
HELPER.GETKEYVALUE(array_of_arrays);
Example
HELPER.ARRAYTOCSV(
[
["Name", "Age", "Location"],
["John Doe", 30, "New York"],
["Jane Smith", 25, "Los Angeles"]
]
);

Result
Name, Age, Location
John Doe, 30, New York
Jane Smith, 25, Los Angeles