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.


SEE ALSO

Release Notes
    • Related Articles

    • File Structure Hierarchy - Java SDK

      In your Java IDE setup, create and arrange the packages containing resource files, properties files, and required jars (ZCRMSDK.jar) as displayed in the image. The numbered items shown in the image are the files to be created in a step wise manner.   ...
    • 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 ...
    • Release Notes - Java SDK

      ZCRMSDK -VERSION 1.0.6  Downloadable JAR file  You can download the jar file for the version1.0.6 of Java SDKs at the end of this page.  Install command - Maven:(in pom.xml)  <repositories>        <repository>              ...
    • Responses & Exceptions - Java SDK

      APIResponse, BulkAPIResponse and FileAPIResponse are the wrapper objects for Zoho CRM APIs’ responses. All API calling methods would return one of these three objects. A method-seeking entity would return APIResponse object, whereas a method-seeking ...
    • Persistence - Java SDK

      Persistent classes in an application implement the entities of the business problem. In Java SDK, two default persistence classes with their implementations are provided. On the other hand, if a developer wants his specific implementation, he can ...