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:
response = ZohoHub.connection.get "CustomModule5"
And the response will be like:
{: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:
- from zcrmsdk import ZCRMModule, ZCRMException
- import zcrmsdk
- def get_records(self):
- try:
- module_ins=ZCRMModule.get_instance('CustomModule5') #module API Name
- resp=module_ins.get_records(page=1, per_page=1)
- record_data = []
- for records in resp.data:
- record_data.append(records.field_data)
- return record_data
- except ZCRMException as ex:
- print(ex.status_code)
- print(ex.error_message)
- print(ex.error_code)
- print(ex.error_details)
- 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:
[{'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.