Kaizen #57 - Mass Update API in Zoho CRM

Kaizen #57 - Mass Update API in Zoho CRM

Hello everyone!

Welcome back to yet another post in the Kaizen series.
This week, we will discuss the Mass Update API in Zoho CRM.

In this post, we will cover the following:
1. Introduction
2. Mass Update Records API 
3. Schedule Update and Get Status
4. Common errors pertaining to the Mass Update API
5. FAQs regarding the Mass Update API

1. Introduction

Generally, there can be cases where you might need to update the same field for multiple/all records in a module. To avoid the tediousness of the task, Zoho CRM offers Mass Update API to update the values of specific fields in multiple records in a module. The request requires field API names, record IDs, the custom view ID, and territory ID as input depending on the type of mass update you intend to perform. 

Mass Update can occur in 2 different ways:
a. Scheduler Type: When you specify the custom view ID and the territory ID, a job gets scheduled in the background. In the response, the system returns a "job_id" which you can use to get the status of the same. Use this job_id in the GET request to get the result. In this type of mass update, You can update a maximum of 50,000 records in a single request.

b. Non-Scheduler Type: When you specify the record IDs, the system updates the records instantly. You can update a maximum of 500 records in a single API call in this type of mass update. 

Modules supporting Mass Update APIs:
Leads, Accounts, Contacts, Deals, Campaigns, Activities, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, and Custom.

2. Mass Update Records API

Request URL: {{api-domain}}/crm/v2/{module_api_name}/actions/mass_update

Scope Required: 
ZohoCRM.mass_update.{module_name}.UPDATE

Request JSON keys:
Key
Data Type
Description
Mandatory
cvid
string
The custom view ID whose records you want to mass update
Mandatory when you want to mass update custom view fields.
over_write

boolean
Used when updating a multi-select picklist field. Providing true will overwrite the already present value while the default false value will add the value to the pick list
Optional
territory
JSON Object
Used to update the records in a territory.
Mandatory when you update territory fields.
ids
JSON Array
Specify the IDs of the records you want to mass update. A maximum of 500 IDs can be specified in the request.
Mandatory when records are updated by IDs.

Sample Request:
{{api-domain}}/crm/v2/Leads/actions/mass_update

Sample Response:


3. Schedule Update and Get Status

Let us see how to schedule a mass update by custom view ID and check it's status:

i. Schedule mass update using 'cvid' and retrieve the 'job_id'.

Sample Request: 
{{api-domain}}/crm/v2/Leads/actions/mass_update

Sample Response:

From the response, you can see that the mass update is scheduled and the job_id to check status is 3719520000001274002

ii. Check status of the scheduled Mass Update

Request URL: 
{{api-domain}}/crm/v2/{module_api_name}/actions/mass_update?job_id={job_id}

Scope Required:
ZohoCRM.mass_update.{module_name}.READ

Note: job_id is the only mandatory parameter that must be passed to obtain the status of the process. 

Sample Request: 
{{api-domain}}/crm/v2/Leads/actions/mass_update?job_id=3719520000001251XXX

Sample Response:
i. Response right after the mass update is scheduled. The status in the response is SCHEDULED.


ii. Response once the schedule is completed. The status in the response is COMPLETED.


Response JSON Keys
Key
Description
Status
Indicates the status of mass update. Possible values are COMPLETED, SCHEDULED, RUNNING, and FAILED.
Failed_Count
Specifies the number of records that failed to be mass updated.
Updated_Count
Specifies the number of records that were successfully mass updated.
Not_Updated_Count
Specifies the number of records that are not updated yet.
Total_Count
Specifies the total number of records that were scheduled to be mass updated

4. Common errors pertaining with the Mass Update APIs and ways to handle them

HTTP Status Code
Error Code
Message
Reason
403
NO_PERMISSION
Field Edit Permission not given
User does not have permission to edit the field
403
NO_PERMISSION
Customview not accessible
Custom view is not accessible to the user of the module
400
NO_RECORDS_FOUND
No record found to update
There are no records in the specified custom view
200
ALREADY_SCHEDULED
Already a Mass Action scheduler is running for the given cvid
The records in the custom view specified are already scheduled for a mass update.
200
LIMIT_EXCEEDED
Record count exceeded
Number of records that can be mass updated has exceeded the maximum allowed limit of 50000
200
RECORD_IN_BLUEPRINT
The record is in blue print
The specified record is in blueprint and user tries to update a blueprint picklist value


5. FAQs regarding Mass Update API

Q. What happens if some record IDs that I provide are invalid?
A: While mass updating records based on their IDs, if some of the record IDs are invalid only those records will not be processed.
Sample Response when one of the ID is invalid:


Q. Can I mass update the email field in the module?
A. No, you cannot mass update Email field. The other fields that cannot be processed for mass update are lookup fields, layout fields, multi line fields, and line items.

Q. Is it possible to mass update the account owner via Zoho CRM API?
A: No, you cannot mass update the account owner via Zoho CRM API. It throws the following error:
{
    "data": [
        {
            "code": "INVALID_DATA",
            "details": {
                "api_name": "Account_Owner"
            },
            "message": "This field cannot be updated in the Mass Update",
            "status": "error"
        }
    ]
}

Q. How to set the scope for custom modules?
A. The process is similar to that of setting scope for any standard module. The scope for Mass Update API is ZohoCRM.mass_update.{module_name}.UPDATE/READ. Hence, for example, if your custom module name is 'Clients', the scope would be 'ZohoCRM.mass_update.Clients.UPDATE/READ

Q. Can I have more than one mass update job for a custom view?
A. No, only one mass update job can happen on a custom view at a given time. An error is thrown with the error code 'ALREADY_SCHEDULED'. 

We hope you found this post useful. Let us know your thoughts in the comment section or reach us out at support@zohocrm.com.

Cheers!









    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now