Class Hierarchy - PHP SDK

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 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. These methods only support API names.
  • To get a field value, use record.getFieldValue(field_api_name);

  • To set a field value, use record.setFieldValue(field_api_name, new_value);

API Names

The keys of the record properties map are the API names of the module’s fields. They are available in your CRM,

Setup → Developer Space → APIs → CRM API → API Names.


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

    • Release Notes - PHP SDK

      ZOHO CRM/PHP SDK 2.0.1 Install command composer require zohocrm/php-sdk:2.0.1 Notes Enhancement Tag names can contain spaces in between them, while associating with records. Tag names can be retrieved as "ZCRMTag" objects in records function. ZOHO ...
    • Installation - PHP SDK

      Install Composer(if not installed) Run this command to install the composer curl -sS  https://getcomposer.org/installer  | php To install composer on mac/ linux machine: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx To install ...
    • PHP SDK - An Overview

      PHP SDK offers a way to create client PHP 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 ...
    • Configuration - PHP SDK

      To access the CRM services through SDK, the client application must be first authenticated. This can be done by passing a key-value configuration pair to the initialization process. The $configuration array must be created. It will contain the ...
    • Initialization - PHP SDK

      The app would be ready to be initialized after defining the configuration array. The user can now proceed to generate the required tokens to run the app. The generation of the grant token can be done using two methods. Self-Client Redirection-based ...