Using Zoho CRM's Python SDK to fetch all records on a module, including lookup fields and related fields.

Using Zoho CRM's Python SDK to fetch all records on a module, including lookup fields and related fields.

Hi everyone. 

So I've been having a tonne of fun using Zoho's APIs to fetch and update records to make any necessary changes to records, saving me a lot of manual effort. 

However, some limitations I seem to notice with the Python sdk's "get_records" function is that:
- A field value only appears if it's actually populated,
- Related fields to that module do not show up.
- Lookup fields do not show up.

I'm wondering if there's any way to force all of the above to show.

Basically, I want to input the API name of the CRM module and then receive the API names of ALL the fields belonging to that module, and then I want to fetch those fields using their API names. 

I have actually been able to do exactly this using an unofficial Ruby SDK, but not with Zoho's own Python SDK.

This is an example of the code using the Ruby SDK that would work:

  1. response  = ZohoHub.connection.get "CustomModule5"
And the response will be like:
  1.  {:Name=>Harry,
      :Mobile=>nil,
      :Subscribed=>false,
      :Owner=>{:name=>"Vanessa", :id=>"4000000000001234567"},
      :Email=>nil :Layout=>{:name=>"customer", :id=>"4000000000009876543"} }
Basically, I get all field up values, related field values, and lookup field values (that I can later parse) using the Ruby SDK's get method.

On the other hand, this is the Python method:
  1. from zcrmsdk import ZCRMModule, ZCRMException
  2. import zcrmsdk

  3. def get_records(self):
  4.     try:
  5.         module_ins=ZCRMModule.get_instance('CustomModule5') #module API Name
  6.         resp=module_ins.get_records(page=1, per_page=1)
  7.         record_data = []
  8.         for records in resp.data:
  9.             record_data.append(records.field_data)
  10.         return record_data
  11.     except ZCRMException as ex:
  12.         print(ex.status_code)
  13.         print(ex.error_message)
  14.         print(ex.error_code)
  15.         print(ex.error_details)
  16.         print(ex.error_content)
Basically, I use the "get_instance" method on the module's API name, then I run "get_records" method followed by "data" method on the result, and I only get the following output:
  1. [{'Name': 'Harry',
      'Subscribed': False}]
Despite the fact that "Email" and "Mobile" show up as API names for this CustomModule5, they're not showing up in this API call. Also, the lookup fields won't appear. 

On the other hand, the API call using the Ruby SDK runs perfectly and fetches everything seen on the API page in the CRM that lists all the fields and related lists of each module.

Even after consulting the Python SDK documentation and experimenting with various examples, nothing seems to work to get my API call to run precisely as I need it to. Any prod in the right direction would be much appreciated. 

      • Sticky Posts

      • How to Add Users to your Organization in ZohoMail?

        A better clarity so you can create other users to start using Zoho Mail. You can directly Add Users from the Control Panel to your Organization. You can invite users with the existing email address. If the person (user) already uses ZohoCRM, then you can import users from Zoho CRM. You can also import them using a .csv file. (if you are planning to add them in Bulk)  In this topic, We will be discussing on how to Add and Invite users only.  The Import options are self explanatory. ____________________________________________________________________________________________________________