Class Hierarchy - Java SDK

Class Hierarchy - Java SDK

All Zoho CRM entities are modelled as classes having members and methods applicable to that particular entity.

  • ZCRMRestClient is the base class of the SDK.
  • This class has, methods to get instances of various other Zoho CRM entities.
  • The class relations and hierarchy of the SDK follows the entity hierarchy inside Zoho CRM.
  • Each class entity has functions to fetch its own properties and to fetch data of its immediate child entities through an API call. For example, a Zoho CRM module (ZCRMModule) object will have member functions to get a module’s properties like display name, module Id, etc, and will also have functions to fetch all its child objects (like ZCRMLayout).

The class hierarchy of various Zoho CRM entities is depicted as:

Instance Objects

It is not always effective to follow the complete class hierarchy from the top to fetch the data of an entity at some lower level, since this would involve API calls at every level. In order to handle this, every entity class will have a getInstance() method to get its own dummy object and methods to get dummy objects of its child entities.

Note
  • getInstance() methods would not have any of its properties filled since it would not fire an API call. This would just return a dummy object that shall be only used to access the non-static methods of the class.

Summing it up,

  • ZCRMRestClient.getModule("Contacts") would return the actual Contacts module, that has all the properties of the Contacts module filled through an API call.
  • ZCRMRestClient.getModuleInstance("Contacts") would return a dummy ZCRMModule object that would refer to the Contacts module, with no properties filled, since this doesn’t make an API call.

Hence, to get records from a module, there's no need to start from ZCRMRestClient. Instead, you could get a ZCRMModule instance with ZCRMModule.getInstance() and then invoke its non-static getRecords() method from the created instance. This would avoid the API call that would otherwise have been triggered to populate the ZCRMModule object.

Accessing record properties

Since record properties are dynamic across modules, we have only given the common fields like createdTime, createdBy, owner etc, as ZCRMRecord’s default members. All other record properties are available as a map in ZCRMRecord object.

To access the individual field values of a record, use the getter and setter methods available. The keys of the record properties map are the API names of the module’s fields. API names of all fields of all modules are available under,

Setup → Marketplace → APIs → CRM API → API Names.

  • To get a field value, use record.getFieldValue(fieldAPIName);
  • To set a field value, use record.setFieldValue(fieldAPIName, newValue);
While setting a field value, please make sure of that the set value is of the data type of the field to which you are going to set it.


    • Related Articles

    • Class Hierarchy - C# SDK

      All Zoho CRM entities are modelled as modules having classes, methods and instance variables applicable to that particular entity. ZCRMRestClient is the base class of the C# SDK. ZCRMRestClient has methods to get instances of various other Zoho CRM ...
    • Class Hierarchy - PHP SDK

      All Zoho CRM entities are modelled as classes having members and methods applicable to that particular entity. ZCRMRestClient is the base class of the SDK. This class has, methods to get instances of various other Zoho CRM entities. The class ...
    • Class Hierarchy - Node JS SDK

      All Zoho CRM entities are modelled as modules having classes, methods and instance variables applicable to that particular entity. ZCRMRestClient is the base class of the Python SDK. ZCRMRestClient has methods to get instances of various other Zoho ...
    • Class Hierarchy - Python SDKs

      All Zoho CRM entities are modelled as modules having classes, methods and instance variables applicable to that particular entity. ZCRMRestClient is the base class of the Python SDK. ZCRMRestClient has methods to get instances of various other Zoho ...
    • Java SDK - Overview

      Java SDK offers a way to create client java applications that can be integrated with Zoho CRM. This SDK makes the access and use of necessary CRM APIs with ease. In other words, it serves as a wrapper for the REST APIs, making it easier to use the ...