Hello everyone!
Welcome back to yet another post in the Kaizen series.
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.
Request URL: {{api-domain}}/crm/v2/{module_api_name}/actions/mass_update
Scope Required:
ZohoCRM.mass_update.{module_name}.UPDATE
Request JSON keys:
Sample Request:
{{api-domain}}/crm/v2/Leads/actions/mass_update
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
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
| | | Reason
|
403
| | Field Edit Permission not given
| User does not have permission to edit the field
|
403
| | Customview not accessible
| Custom view is not accessible to the user of the module
|
400
| | No record found to update
| There are no records in the specified custom view
|
200
| | 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
| | Record count exceeded
| Number of records that can be mass updated has exceeded the maximum allowed limit of 50000
|
200
| | 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!