Skip to product menu
close
  • Recent Launches
    Press Space or Enter to display list of options
EXPLORE ALL PRODUCTS

Recent Launches

New

Payroll software with automated tax payments and filing.

Try now
New

Robotic process automation software to automate high-volume, rule-based tasks.

Try for free
New

Low-code IoT platform and solutions for connected businesses.

Try now
New

Business formation service to launch and grow your businesses.

Try now
New

Privacy-friendly application analytics solution.

Try for free

Sales

 
CRM

Comprehensive CRM platform for customer-facing teams.

CRM
 
Bigin

Simple CRM for small businesses moving from spreadsheets.

Bigin
 
Forms

Build online forms for every business need.

Forms
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
Sign

Digital signature app for businesses.

Sign
 
RouteIQ

Comprehensive sales map visualization and optimal route planning solution.

RouteIQ
 
Thrive

Complete loyalty and affiliate management platform.

Thrive
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
Suites
CRM Plus

Unified platform to deliver top-notch customer experience.

CRM Plus

Marketing

 
Social

All-in-one social media management software.

Social
 
Campaigns

Create, send, and track targeted email campaigns that drive sales.

Campaigns
 
Forms

Build online forms for every business need.

Forms
 
Survey

Design surveys to reach and interact with your audience.

Survey
 
Sites

Online website builder with extensive customisation options.

Sites
 
PageSense

Website conversion optimization and personalisation platform.

PageSense
 
Backstage

End-to-end event management software.

Backstage
 
Webinar

Webinar platform for webcasting online webinars.

Webinar
 
Marketing Automation

All-in-one marketing automation software.

Marketing Automation
 
LandingPage

Smart landing page builder to increase conversion rates

LandingPage
 
Publish

Manage all your local business listings on a single platform.

Publish
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Sign

Digital signature app for businesses.

Sign
 
Thrive

Complete loyalty and affiliate management platform.

Thrive
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
NEW
LeadChain

Sync, manage, and convert leads across channels seamlessly.

LeadChain
 
NEW
CommunitySpaces

Online community platform for individuals and businesses to grow their network and brand.

CommunitySpaces
 
Suites
Marketing Plus

Unified marketing platform for marketing teams.

Marketing Plus

Commerce and POS

 
Commerce

eCommerce platform to manage and market your online store.

Commerce

Service

 
Desk

Helpdesk software to deliver great customer support.

Desk
 
Assist

Remote support and unattended remote access software.

Assist
 
Lens

Interactive remote assistance software with augmented reality.

Lens
 
FSM

End-to-end field service management platform for service businesses.

FSM
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
Suites
Service Plus

Unified platform for customer service and support teams.

Service Plus

Finance

 
Books

Powerful accounting platform for growing businesses.

Books
 
FREE
Invoice

100% Free invoicing solution.

Invoice
 
Expense

Effortless expense reporting platform.

Expense
 
Inventory

Powerful stock management and inventory control software.

Inventory
 
Billing

End-to-end billing solution for your business.

Billing
 
Checkout

Collect payments online with custom branded pages.

Checkout
 
NEW
Payroll

Payroll software with automated tax payments and filing.

Payroll
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo
 
Practice

Practice management software for accounting firms.

Practice
 
Sign

Digital signature app for businesses.

Sign
 
Commerce

eCommerce platform to manage and market your online store.

Commerce
 
Suites
Finance Plus

All-in-one suite to manage your operations and finances.

Finance Plus

Email and Collaboration

 
Mail

Secure email service for teams of all sizes.

Mail
 
Meeting

Online meeting software for all your video conferencing & webinar needs.

Meeting
 
Writer

Word processor for focused writing and discussions.

Writer
 
Sheet

Spreadsheet software for collaborative teams.

Sheet
 
Show

Create, edit, and share slides with a sleek presentation app.

Show
 
Notebook

Beautiful home for all your notes.

Notebook
 
Cliq

Stay in touch with teams no matter where you are.

Cliq
 
Connect

Employee experience platform to communicate, engage, and build positive employee relations.

Connect
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
TeamInbox

Shared inboxes for teams.

TeamInbox
 
WorkDrive

Online file management for teams.

WorkDrive
 
Sign

Digital signature app for businesses.

Sign
 
Office Suite

Powerful collaborative work platform for teams.

Office Suite
 
Office Integrator

Built in document editors for web apps.

Office Integrator
 
ZeptoMail

Secure and reliable transactional email sending service.

ZeptoMail
 
Calendar

Online business calendar to manage events and schedule appointments.

Calendar
 
Learn

Knowledge and learning management platform.

Learn
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
ToDo

Collaborative task management for individuals and teams.

ToDo
 
Tables

Work management tool to connect people, processes, and information.

Tables
 
FREE
PDF Editor

Collaborative online PDF editing tool.

PDF Editor
 
Suites
Workplace

Application suite built to improve team productivity and collaboration.

Workplace

Human Resources

 
People

Organize, automate, and simplify your HR processes.

People
 
Recruit

Intuitive recruiting platform built to provide hiring solutions.

Recruit
 
Expense

Effortless expense reporting platform.

Expense
 
Workerly

Manage temporary staffing with an employee scheduling solution.

Workerly
 
NEW
Payroll

Payroll software with automated tax payments and filing.

Payroll
 
Shifts

Employee scheduling and time tracking app.

Shifts
 
Sign

Digital signature app for businesses.

Sign
 
Suites
People Plus

Comprehensive HR platform for seamless employee experiences.

People Plus

Security and IT Management

 
Creator

Build custom apps to simplify business processes.

Creator
 
Directory

Workforce identity and access management solution for cloud businesses.

Directory
 
FREE
OneAuth

Secure multi-factor authenticator (MFA) for all your online accounts.

OneAuth
 
Vault

Online password manager for teams.

Vault
 
Catalyst

Pro-code platform to build and deploy your apps.

Catalyst
 
Toolkit

Complete resource for any admin-related lookup queries.

Toolkit
 
Lens

Interactive remote assistance software with augmented reality.

Lens
 
Assist

Remote support and unattended remote access software.

Assist
 
QEngine

Test automation software to build, manage, execute, and report testcases.

QEngine
 
NEW
RPA

Automate manual, tedious, and repetitive tasks easily.

RPA

BI and Analytics

 
Analytics

Modern self-service BI and analytics platform.

Analytics
 
Embedded BI

Embedded analytics and white label BI solutions, tailored for your needs.

Embedded BI
 
DataPrep

AI-powered data preparation service for your data-driven organization.

DataPrep
 
NEW
IoT

Harnessing IoT analytics for real-time operational intelligence.

IoT

Project Management

 
Projects

Manage, track, and collaborate on projects with teams.

Projects
 
Sprints

Planning and tracking tool for scrum teams.

Sprints
 
BugTracker

Automatic bug tracking software for managing bugs.

BugTracker
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo

Developer Platforms

 
Creator

Build custom apps to simplify business processes.

Creator
 
Flow

Automate business workflows by creating smart integrations.

Flow
 
Catalyst

Pro-code platform to build and deploy your apps.

Catalyst
 
Office Integrator

Built in document editors for web apps.

Office Integrator
 
ZeptoMail

Secure and reliable transactional email sending service.

ZeptoMail
 
QEngine

Test automation software to build, manage, execute, and report testcases.

QEngine
 
Tables

Work management tool to connect people, processes, and information.

Tables
 
NEW
RPA

Automate manual, tedious, and repetitive tasks easily.

RPA
 
NEW
Apptics

Application analytics for all apps.

Apptics
 
Embedded BI

Embedded analytics and white label BI solutions, tailored for your needs.

Embedded BI
 
NEW
IoT

Build, deploy, and scale IoT solutions for connected businesses.

IoT
 
DataPrep

AI-powered data preparation service for your data-driven organization.

DataPrep

IoT

 
NEW
IoT

Low-code IoT platform and solutions for connected businesses.

IoT

Search Result

 
CRM Plus

Unified platform to deliver top-notch customer experience.

Try now
CRM Plus
 
Service Plus

Unified platform for customer service and support teams.

Try now
Service Plus
 
Finance Plus

All-in-one suite to manage your operations and finances.

Try now
Finance Plus
 
People Plus

Comprehensive HR platform for seamless employee experiences.

Try now
People Plus
 
Workplace

Application suite built to improve team productivity and collaboration.

Try now
Workplace
 
Marketing Plus

Unified marketing platform for marketing teams.

Try now
Marketing Plus
 
All-in-one suite

Zoho One

The Operating System for Business

Run your entire business on Zoho with our unified cloud software, designed to help you break down silos between departments and increase organizational efficiency.

TRY ZOHO ONE
Zoho One
Zoho Marketplace

With over 2000 ready-to-use extensions across 40+ categories, connect your favorite business tools with the Zoho products you already use.

EXPLORE MARKETPLACE
Marketplace

Join us for the biggest low-code event of the year. Register now!

x
Skip to main content

Choose where you’d like to start

Collection variable

Note:
  • Collection variable is not to be confused with the collection data type. To learn about the collection data type, which is used to hold an index-value collection or a key-value collection, refer to this page.
  • This help page is applicable only to Zoho Creator.

Overview

When you fetch a collection of one or more records, you get a collection variable.

Declaring a collection variable

<collection_variable> = <form> [<criteria>];

Example

In the following example, the variable named employeesJoinedToday contains records of employees who have joined today. Joining_Date is the link name of a field in the Employees form.

employeesJoinedToday = Employees [Joining_Date == zoho.currentdate];

Note:

  • When the "sort" param is not specified, the fetched records are often sorted based on "added time" (oldest first) system field. However, there is no guarantee to this order and there is no guarantee that the order will remain constant over time. If you are particular about the sequence of the records, it is advisable to use the sort param.
  • The Name and Address fields do not work with the sort by param.

Aggregate functions

You can use the following syntax to perform various functions:

<collection_variable> = <form> [<criteria>].<method>;

(or)

<collection_variable>.<method>;

Following are the methods that can be performed:

  • avg(<field_link_name>) ​

    Returns: Average of all values of a specified field in a collection of records.
    Applicable field types and the return type: Percent, Currency, Decimal, Formula(decimal) and Formula(bigint and decimal) field types will return Decimal data-type. Number and Formula(bigint) field types will return Bigint data-type.

  • count(<field_link_name>) ​

    Returns: Count of records in a collection when the <field_link_name> is not specified. Else, it returns the number of values the specified field holds.
    Return type: Bigint.
    Applicable field types: Multi select, Checkbox, Drop-down and Radio fields will return the count of choices selected. All other field types will return the count of records in which the specified field is not null. 

  • distinct(<field_link_name>) ​

    Returns: Distinct values a field holds in a collection of records.
    Return type: List.
    Applicable field types: All field types.

  • maximum(<field_link_name>) ​

    Returns: Largest value of a specified field in a collection of records
    Applicable field types and the return type: Percent, Currency, Decimal, Formula(decimal) field types will return Decimal data-type. Number and Formula(bigint) field types will return Bigint data-type. Date and Date-Time field types will return Timestamp data-type.

  • median(<field_link_name>) ​

    Returns: Median value of a specified field in a collection of records sorted in ascending order.
    Applicable field types and the return type: Percent, Currency, Decimal, Formula(decimal) field types will return Decimal data-type. Number and Formula(bigint) field types will return Bigint data-type.​

  • minimum(<field_link_name>) ​

    Returns: Smallest value of a specified field in a collection of records.
    Applicable field types and the return type: Percent, Currency, Decimal, Formula(decimal) field types will return Decimal data-type. Number and Formula(bigint) field types will return Bigint data-type. Date and Date-Time field types will return Timestamp data-type.

  • sum(<field_link_name>) ​

    Returns: Total of all values of a specified field in a collection of records.
    Applicable field types and the return type: Percent, Currency, Decimal, Formula(decimal) field types will return Decimal data-type. Number and Formula(bigint) field types will return Bigint data-type.

Fetch field value from the first record

To fetch a field value from the first record in a collection, use the following code:

<variable> = <collection_variable>.<field_link_name>;

where,

<field_link_name>

Link name of the field whose value has to be returned from the first record in the collection.

Example

The following syntax returns the employee id of the first record in collection variable employeesJoinedToday, and stores it the variable named empID. Employee_ID is the link name of a field.

empID = employeesJoinedToday.Employee_ID;

Fetch values of a field from all the records in a collection

<variable> = <collection_variable>.<field_link_name>.getAll();

where,

<field_link_name>

Link name of the field whose values have to be returned from all the records in the collection.

Example

The following syntax returns the employee id field values from all the records in collection variable employeesJoinedToday, and stores it the variable named empID. Employee_ID is the link name of a field.

empID = employeesJoinedToday.Employee_ID.getAll();

Iterating through records in a collection variable

To iterate through the records in a collection variable, use the following code:

for each <record_variable> in <collection_variable>
  {
     fieldValue = <record_variable>.<field_link_name>;
  }

where,

<record_variable>

Variable to hold the record for each iteration.

<field_link_name>

Link name of the field whose value has to be returned.

fieldValue

Variable to hold the specified field's value for each iteration.

The data-type of the returned value will depend on the field type. 

This table lists the applicable data-type for each field.

Example

The following code iterates through the records in collection variable employeesJoinedToday, and sends an email to each email address present in the collection. Email is the link name of the email field type.

for each employee in employeesJoinedToday
  {
      sendmail
         [
           from: zoho.adminuser
           to: employee.Email
           subject: "Zylker : Offer Letter"
           message: "Welcome to Zylker. Please find your offer letter attached with this email."
         ]  
   }

Updating field value in a collection variable

  • To update a field value in the first record in a collection, use the following syntax:

    <collection_variable>.<field link name> = <expression>;

    where,

    <field_link_name>

    Link name of the field whose value has to be updated.

    <expression>

    Updated value to be assigned to the field. The data-type of this value must match the data-type of the field. Any mismatch in the data-type will stop the execution during runtime.

    See the table below to understand more about the applicable values for each field type.

  • ​​To update a field value in every record in a collection, use the below code:

    for each <record_variable> in <collection_variable>
    {
    <record_variable>.<field_link_name> = <expression>;
    }

    where,

    <record_variable>

    Variable to hold the record for each iteration

    <field_link_name>

    Link name of the field whose value has to be updated.

    <expression>

    Updated value to be assigned to the field. The data-type of this value must match the data-type of the field. Any mismatch in the data-type will stop the execution during runtime.

    See the table below to understand more about the applicable values for each field type.

Example

The following syntax updates the Batch Sequence("number" field type) field with the value 118 for all the records in the collection variable employeesJoinedToday.

for each emp in employeesJoinedToday
  {
    emp.Batch_Sequence = 118;
  }

Applicable values for each field type

Field typeData-typeApplicable notes
NameText

You must specify only the link name of the "Name" field when assigning it a value copied from another "Name" field.

In all other cases, you have to give the values for its sub-fields separately as given below:

<field>.prefix: denotes the "prefix" field.

<field>.first_name: denotes the "first_name" field.

<field>.last_name: denotes the "last_name" field.

<field>.suffix: denotes the "suffix" field.

You can set value for the above mentioned sub-fields even if they are not selected in the field's property.

Note:

  • If more than one Name fields are present in the form, the link names of the subsequent name sub fields will be appended by a number starting from 1. So, if we take the example of the subfield <field>.prefix, the link name of the first such field will be <field>.prefix, the link name of the second such field will be <field>.prefix1, the link name of the third such field will be <field>.prefix2, and so on. 
EmailText

The format of the specified email address must be valid. If the format of the specified email address is invalid, execution will be stopped during runtime.

The number of characters in the value should not exceed the length specified in the "Character maximum" field property. If it exceeds, execution will be stopped during run-time.

AddressText

You must specify only the link name of the "Address" field when assigning it a value copied from another "Address" field.

In all other cases, you have to give values for its sub-fields separately as given below:

<field>.address_line_1: denotes the "Address Line 1" field.

<field>.address_line_2: denotes the "Address Line 2" field.

<field>.district_city: denotes the "City / District" field.

<field>.state_province: denotes the "State / Province" field.

<field>.postal_Code: denotes the "Postal Code" field.

<field>.country: denotes the "Country" field.

<field>.longitude: denotes the "longitude" field.

<field>.latitude: denotes the "latitude" field.

You can set values for the above mentioned sub-fields even if they are not selected in the field's property.

Note:

  • If more than one address fields are present in the form, the link names of the subsequent address sub fields will be appended by a number starting from 1. So, if we take the example of the subfield <field>.country, the link name of the first such field will be <field>.country, the link name of the second such field will be <field>.country1, the link name of the third such field will be <field>.country2, and so on. 
PhoneText

Value can be specified with or without the country code, even if the "Country code options" and "Default country code" field properties are not selected.

Special characters like (), and - are supported to accept different phone number formats of various countries.

Single LineTextThe number of characters in the value should not exceed the length specified in the "Character maximum" field property. If it exceeds, execution will be stopped during run-time.
Multi LineTextThe value can be plain text of maximum 64 kb size.
NumberNumberIf the number of digits specified in the value exceeds the length specified in the "Max Digits" field property, the extra digits will be trimmed from the right.
DateDate-time

All dates in a week can be specified as value, irrespective of the selected days in "Allowed Days" property.

Time value, if specified, will not get added.

Drop DownText

You can specify a new choice apart from pre-defined choices even if the "Allow Other Choice" field property is not selected.

If a new choice is specified as the value, it only gets saved in the record and is not added as a new choice to be selected from the form UI. And that choice cannot be retrieved back if modified.

RadioText

You can specify a new choice apart from existing choices even if the "Allow Other Choice" field property is not selected.

If a new choice is specified as the value, it only gets saved in the record and is not added as a new choice to be selected from the form UI. And that choice cannot be retrieved back if modified.

Multi SelectText list

You can specify a new choice apart from the pre-defined choices.

If a new choice is specified as the value, it only gets saved in the record and is not added as a new choice to be selected from the form UI. And, if you change that choice and update the record, the choice will no longer be available.

CheckboxText list

You can specify a new choice apart from the pre-defined choices.

If a new choice is specified as the value, it only gets saved in the record and is not added as a new choice to be selected from the form UI. And, if you change that choice and update the record, the choice will no longer be available.

Decision boxBoolean

You must specify the value as True or False, with or without double quotes.

If any other value is specified, execution will be stopped during run time.

Rich TextTextThere is no restriction to the number or type of characters that can be specified as the value.
UrlText

Value must be specified in the following format (title, linkname and target are optional params) :

<a href= \"<URL>\" title = \"<TITLE>\" target = \"_blank\"><linkname></a>

If a url is specified directly, the URL field will get saved with a null value.

ImageText

Value must be specified in the following format (title, linkname and target are optional params) :

<a href= \"http://<LINKNAME>\" title =\"<TITLE>\" target = \"_blank\"><img src = \"<URL>\" title =\"<TITLE>\"></img></a>

You must specify the image url as the value, even if the "Browse Options -Link" field property is not selected.

PercentDecimal

If the number of digits specified in the value exceeds the length specified in the "Max Digits" field property, the extra digits will be trimmed from the right.

If the specified decimal points exceed the number specified in "Decimal Points" field property, the extra decimal points will be trimmed from the right. 

CurrencyDecimal

If the number of digits specified in the value exceeds the value specified in the "Max Digits" field property, the extra digits will be trimmed from the right.

If the specified decimal points exceed the number specified in "Decimal Points" field property, the extra decimal points will be trimmed from the right. 

DecimalDecimal

If the number of digits specified in the value exceeds the value specified in the "Max Digits" field property, the extra digits will be trimmed from the right.

If the specified decimal points exceed the number specified in "Decimal Points" field property, the extra decimal points will be trimmed from the right.

Date-TimeDate-time

All days and hours can be specified as value, irrespective of the selected days and hours in "Allowed Days" and "Allowed Hours" property. 

If Time value is not specified, 00:00:00 will be set as the time value.

Lookup

(Display type - Dropdown/Radio Button)

Number

You must specify the record id of the lookup form as the value. 

Lookup

(Display type - Multi Select/Checkbox)

Number listYou must specify the record ID of the lookup form as the value.
File UploadFile UploadOnly a file value fetched from another File Upload field type should be specified as a value.
AudioAudioOnly an audio file fetched from another Audio field type can be specified as a value.
VideoVideoOnly a video file fetched from another Video field type can be specified as a value.
FormulaNumber/Text/DecimalFormula field is a read-only field type.
UsersText

You can specify username of any user or developer added in your current app. 

You can view the list of users and developers in your account by navigating to Settings > Users. From this page, you can also add more users and developers to your account.

If you enter an incorrect username, execution will be stopped during run-time.

You must only specify the username even if the "Field type" field property is set to Email Id.

Integration (Zoho CRM)Text

You must specify the record id in the selected module as the value. If you enter an incorrect id, execution will be stopped during run-time. 

Learn how to fetch the ID of a record after creating it or fetching it.

Integration (Zoho Recruit)Text

You must specify the record id in the selected module as the value. If you enter an incorrect id, execution will be stopped during run-time.

Learn how to fetch the ID of a record after creating it or fetching it.

Integration (Salesforce)Text

You must specify the record id in the selected module as the value. If you enter an incorrect id, execution will be stopped during run-time.

Learn how to fetch the ID of a record after creating it or fetching it.

Integration (Zoho Books)Text

You must specify the record id in the selected module as the value. If you enter an incorrect id, execution will be stopped during run-time.

Learn how to fetch the ID of a record after creating it or fetching it.

Integration (Quickbooks)Text

You must specify the record id in the selected module as the value. If you enter an incorrect id, execution will be stopped during run-time.

Learn how to fetch the ID of a record after creating it or fetching it.

Note:

  • A collection variable can be passed as a form object in a function. 

Get Started Now

Execute