Contents

Cancel

Recommended Articles

  1. unify-apps

    Indexing

    Unify AI

    Transform raw content into searchable knowledge through AI-powered indexing and vector embeddings

  2. unify-apps

    JobNimbus

    Unify Integrations

    Integrate your application with JobNimbus to manage leads, track jobs, and streamline your workflow processes efficiently

  3. unify-apps

    IMAP

    Unify Integrations

    Integrate your app with IMAP to enable seamless email synchronization, real-time access, and enhanced communication workflows.

  4. unify-apps

    Preview Your Work

    Unify Automations

    Effortlessly review & monitor your automation’s performance

  5. unify-apps

    QuickBooks

    Unify Integrations

    Integrate your app with QuickBooks to streamline accounting, automate invoicing, and manage finances effortlessly

  6. unify-apps

    FTP/FTPS

    Unify Integrations

    Connect your app with FTP/FTPS to automate secure file transfers and streamline data exchange across systems.

  7. unify-apps

    Filters

    Unify Applications

    Enable users to refine, search, and sort data effortlessly across dashboards and datasets

  8. unify-apps

    Insided

    Unify Integrations

    Integrate your app with Insided to enhance customer engagement, streamline community management, and drive self-service support.

  9. unify-apps

    Facebook Ads

    Unify Integrations

    Connect your app with Facebook Ads to automate campaign management, optimize ad performance, and track marketing success.

  10. unify-apps

    Gainsight

    Unify Integrations

    Integrate your app with Gainsight to enhance customer success, automate engagement workflows, and drive retention

  11. unify-apps

    Livestorm

    Unify Integrations

    Integrate your app with Livestorm to streamline webinar hosting, automate event management, and enhance audience engagement.

  12. unify-apps

    Snowflake

    Unify Automations

    Connect to Snowflake for fast, scalable cloud data warehousing and analytics

  13. unify-apps

    Pipeline CRM

    Unify Integrations

    Integrate your app with Pipeline CRM to streamline sales processes, automate lead management, and enhance customer relationships

  14. unify-apps

    Cognito Forms

    Unify Integrations

    Integrate your app with Cognito Forms to create custom forms, automate data collection, and streamline workflows

  15. unify-apps

    Button

    Unify Applications

    Create interactive elements with ease using buttons

  16. unify-apps

    BambooHR

    Unify Automations

    Integrate your app with BambooHR to streamline HR management, automate employee data processing, and enhance onboarding workflows

  17. unify-apps

    Build your first automation

    Unify Automations

    Learn how to build your automation step by step

  18. unify-apps

    User Management

    Unify Applications

    Efficiently manage user roles and permissions

#
Unify Applications
Logo
Add Data Sources
Logo
JS Variables and Functions

JS Variables and Functions

Logo

5 mins READ

Overview

JavaScript variables and functions can be used for handling data in your application. Variables act as containers to store information (like numbers, text, or lists), while functions can be used as custom code blocks that can execute any javascript process. 

Variables

Variables can be used across a page in your low code application to form logics. They can also act as conditions for the behavior of UI components and interactions.

These can be named using the name field and the data type can be selected from the given options. For example, creating a variable named ‘var’ with initial value as 1.

Data Types 

  • Number

    • Represents numeric values (both integers and floating-point).

    • JavaScript does not differentiate between integers and floats.

  • String

    • Represents sequences of characters (text).

    • Can be created using single quotes, double quotes, or backticks (for template literals).

  • Boolean

    • Represents a logical entity and has only two values: true or false.

  • Object

    • Objects are collections of key-value pairs. Values can be of any type, including other objects and functions.

    • Objects are versatile and form the basis for more complex data structures like arrays and functions.

  • Array

    • Arrays are lists that can store multiple values in an ordered way.

Image
Image


Initialization

This field allows you to set static initial value or map a data pill as the initial value. This is an optional field and can be filled if any default value is necessary.

Image
Image
Thumbnail

Refer

You can refer to Component Specific Documentation to know more about data pills for each component.

Interactions for variables

Each variable type (Array, String, Boolean, Object, Number) has specific operations available as mentioned in the interactions list below. These operations help you manipulate the stored data according to your needs.

Operation

Applicable Variable type

Function

Set value

Array, string, boolean, object, number

This operation is used to set value for a variable

Add to beginning

Array, string

This operation inserts an element at the beginning of a variable.

Add to end

Array, string

This operation inserts an element at the end of a variable.

Remove from first

Array

This operation is used to remove the first element of an array.

Remove from last

Array

This operation is used to remove the last element of an array.

Toggle value

Boolean

This operation toggles the current value of a variable. 

Increment by

Number

This operation increases the value of a number variable.

Decrement by

Number

This operation decreases the value of a number variable.

Merge properties

Object

This operation is used to combine the mentioned properties with the object variable.

Use case for a Variable

Here is a sample use case of variables where you can create a variable named ‘organisation’ and use it to assign default value to a form. 

Image
Image

Functions

Functions in Javascript are designed to perform custom tasks. Functions can take inputs (parameters), operate on those inputs, and return a result. JavaScript offers several ways to define functions . You can also use data pills as input to create data sources by directly selecting the pill as required. You can then return the value of the function.

Use case for a function

You can write a Javascript function to fetch the current date formatted in Month - Day - Year and map the values in the UI components. In case there are multiple values in the functions, return them by creating a javascript object.

Image
Image

Best Practices

  • Naming Conventions - Keep names concise and clear enough to understand their purpose

  • Initialization - Initialize variables with appropriate default values.

  • Returning a function value - Return consistent data types to avoid any type mismatch.

FAQs

Can I use Javascript functions to create UI elements? 

No, functions in data sources can’t be used to create UI elements. They are strictly meant to create data sources. For custom UI components using javascript, refer page settings.