How to Retrieve More than 200 Records from a Zoho CRM Module Custom View

How to Fetch more than 200 records in zoho crm using deluge dynamically

Objective:

Get more than 200 records from a custom view in a Zoho CRM module. By default, the zoho.crm.getRecords API fetches only 200 records per page. To retrieve each page of records using Zoho CRM Variable, Follow these steps:

Steps:

  1. Navigate to CRM Settings:

    • Click on the Settings icon in the top right corner of your Zoho CRM dashboard.
    • Navigate the Developer Hub, click on Variables.
  2. Create a CRM Variable:

    • Click on Create Variable.
    • In the "Variable Name" field, enter "Page".
    • Set Variable Type to Number.
    • In the Value field, enter 1 (as the initial page number).
    • Under Grouped Under, choose the appropriate variable grouping.
    • Click Save.
  3. Create a Scheduler:

    • Navigate to the Automation section in Zoho CRM.
    • Click on Schedulers.
    • Click on Create New Scheduler to set up a function that runs at regular intervals for data retrieval.
  4. Define a Function for the Scheduler:

    • After creating the scheduler, you'll need to write a function that handles fetching records across multiple pages.

    • Define an argument for the function that dynamically references the page number. Follow these steps:

      a) In the scheduler function, click on Edit Argument.

      b) Enter Argument Name as "page".

      c) In the Value field, click on the dropdown and choose Zoho CRM Variable.

      d) Select your variable group (Grouped Name), and choose the Page variable you created earlier.

      e) Save the argument setup.

  5. Write the Script:

    • Now, within the function, write a Deluge script that handles fetching records page by page.








Please find the below Scheduler Code:-

getdata = zoho.crm.getRecords("Accounts", page, 200, {"cvid": XXXXXX000000029468});

info getdata;

if(getdata.size() == 0)

{

valueMap = Map();

valueMap.put("apiname", "Page");

valueMap.put("value", page +1);

resp =zoho.crm.invokeConnector("crm.set", valueMap);

info resp;

}

Note : Replace XXXXXX000000029468 : with your Custom view ID,Using the above code to iterate the Record page wise. You have to found the Custom-view ID in the Module Url.












6. Save and Schedule:

  • Save the function and set up the scheduler to run at the desired interval (e.g.,2 hours, every day or week, depending on the requirement).
  • This setup allows you to fetch more than 200 records in batches by automatically paginating through the records using the zoho.crm.getRecords API and updating the page variable.

Post a Comment