Fetch records

Fetch records

Note:

  • This task is applicable only to Zoho Creator.

Overview

The fetch record deluge task retrieves records from a specified form, when a given criteria is met.

The criteria is mandatory.

See this page to learn about fetching all values of a field in a collection.

See this page to learn about fetching a specified field's value from the first record in the collection.

Note:

  • The fetched records may appear to be 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.

Return

This task returns a collection of records.

Syntax

To fetch records which meet a criteria

<variable> = <form_link_name>[<criteria>];

To fetch records which meet a criteria, and sort them in ascending order based on a field

<variable> = <form_link_name>[<criteria>] sort by <field_link_name>;

To fetch records which meet a criteria, and sort them in descending order based on a field

<variable> = <form_link_name>[<criteria>] sort by <field_link_name> desc;

To fetch records within a specified range, which meet a criteria

<variable> = <form_link_name>[<criteria>] range from <start_index> to <end_index>;  

To fetch records within a specified range, which meet a criteria, and sort them in ascending order based on a field

<variable> = <form_link_name>[<criteria>] sort by <field_link_name> range from <start_index> to <end_index>;

To fetch records within a specified range, which meet a criteria, and sort them in descending order based on a field

<variable> = <form_link_name>[<criteria>] sort by <field_link_name> desc range from <start_index> to <end_index>;

ParameterDescription
<variable>

Collection variable holding the collection of records.

<form_link_name>

Link name of the form from which the records will be fetched.

<criteria>

Criteria based on which records will be fetched. 

sort by <field_link_name>

Link name of the field based on which records will be sorted.

Note: A lookup field will sort the records based on the record ID.

range from <start_index> to <end_index>

Records included in the specified index range will be fetched.

<start_index>

Start index of the range of records to be fetched. 

Either 0 or 1 may be specified as the index number of the first record when used in <start_index> param.
If 0 is the specified start index, the last index is numbered from 0. If 1, or any number greater than 1, is the specified start index, the last index is numbered from 1.

E.g. for records A (index 1), B (index 2), C (index 3), D (index 4), and E (index 5):

Range from 0 to 3 will fetch A, B, C, D
Range from 1 to 4 will fetch A, B, C, D
Range from 2 to 4 will fetch B, C, D

<end_index>

Last index of the range of records to be fetched, inclusive.

Negative index values will result in a runtime error.

Things to keep in mind

  • If you wish to fetch all records of the specified form, use the following script as criteria:
    [ID != 0]

    It is advisable to fetch all records only when absolutely needed. Fetching all records generates a load resulting in performance issues.
     
  • If you wish to use the "sort" and "range" parameters together, the "sort" parameter should be followed by the "range" parameter.
     
  • If specifying the Name or Address field in the criteria, it is mandatory to specify their subfields as shown below:
    • Name.first_name
    • Name.last_name
    • Name.prefix
    • Name.suffix
    • Address.address_line_1
    • Address.address_line_2
    • Address.district_city
    • Address.state_province
    • Address.postal_Code
    • Address.country
    • Address.longitude
    • ​Address.latitude  

      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. The same logic applies to the Address subfields.
       
  • The Name and Address fields do not work with the sort by param

This task can be used in the following events

When a record is Created
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Created or Edited
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Edited
On LoadYes
On ValidateYes
On SuccessYes
On User inputYes
Subform on add rowYes
Subform on delete rowYes
When a record is Deleted
On ValidateYes
On SuccessYes
Other workflow events
On a scheduled dateYes
During approval processYes
During payment processYes
In a Custom FunctionYes
In an Action item in reportYes

Examples

1) The following snippet can be used to extract specified field value from the most recently added record.

EmployeeDetails = Employees [ ID != 0] sort by Added_Time desc;
info EmployeeDetails.<field_link_name>;   // picks up the first record from the collection

2) The following script fetches all records which have the "age" field value as "25", from the Employees form.

EmployeeDetails = Employees [ age == "25" ];

3) The following script fetches all records which have the "name" field value as "Edward Thomas" or "Robert Frost", from the Poets_Form form.

poets = {"Edward Thomas", "Robert Frost"};
Poet_Details = Poets_Form [ name in poets ];

4)The following script fetches all records which have the "name" field value as "Jon Berryman". The name value is then updated to "John Berryman".

EmployeeDetails = Employee[name == "Jon Berryman"];
for each employee in EmployeeDetails
{
employee.name = "John Berryman" ;  
}

5) The following script fetches all records(because no record will have ID as 0) and sorts them by their Names. The Range is specified as 0 to 2, hence only the first 3 records will be fetched.

EmployeeDetails = Employee[ID != 0] sort by name range from 0 to 2;

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com