PHP SDK Sample

PHP SDK Sample

Here is the sample PHP code block for the getFieldDetails method.

  1. <?php
  2. require 'vendor/autoload.php';
  3. class Module{
  4.     public function __construct()
  5.     {
  6.         ZCRMRestClient::initialize();
  7.     }
  8.     public function getFieldDetails() {
  9.         $moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Leads"); //To get module instance
  10.         $response=$moduleIns->getFieldDetails("3524033000000002589"); //to get the field
  11.         $field=$response->getData(); //to get the field data in form of ZCRMField instance.
  12.         echo $field->getApiName(); //to get the field api name
  13.         echo $field->getLength();//to get the length of the field value
  14.         echo $field->isVisible();//to check if the field is visible
  15.         echo $field->getFieldLabel();//to get the field label name
  16.         echo $field->getCreatedSource();//to get the created source
  17.         echo $field->isMandatory();//to check if the field is mandatory
  18.         echo $field->getSequenceNumber();//to get fields sequence number
  19.         echo $field->isReadOnly();//to check if the field is read only
  20.         echo $field->getDataType();//to get the field data type
  21.         echo $field->getId();//to get the field id
  22.         echo $field->isCustomField();//to check if the field is custom field
  23.         echo $field->isBusinessCardSupported();//to check if the field is BusinessCard Supported
  24.         echo $field->getDefaultValue();//to get the default value of the field
  25.         $permissions= $field->getFieldLayoutPermissions();//get field layout permissions.array of permissions list like CREATE,EDIT,VIEW,QUICK_CREATE etc.
  26.         foreach($permissions as $permission){//for each permission
  27.             echo $permission;
  28.         }
  29.         $lookupfield=$field->getLookupField();//to get the field lookup information
  30.         if($field->getDataType()=="Lookup"){
  31.             echo $lookupfield->getModule();////to get the module name of lookupfield
  32.             echo $lookupfield->getDisplayLabel();//to get the display label of the lookup field
  33.             echo $lookupfield->getId();//to get the id of the lookup field
  34.         }
  35.         $picklistfieldvalues =$field->getPickListFieldValues();//to get the pick list values of the field
  36.         foreach ($picklistfieldvalues as $picklistfieldvalue){
  37.             echo $picklistfieldvalue->getDisplayValue();//to get display value of the pick list
  38.             echo $picklistfieldvalue->getSequenceNumber();//to get the sequence number of the pick list
  39.             echo $picklistfieldvalue->getActualValue();//to get the actual value of the pick list
  40.             echo $picklistfieldvalue->getMaps();
  41.         }
  42.         echo $field->isUniqueField();//to check if the field is unique
  43.         echo $field->isCaseSensitive();//to check if the field is case sensitive
  44.         echo $field->isCurrencyField();//to check if the field is currency field
  45.         echo $field->getPrecision();//to get the precision of the field
  46.         echo $field->getRoundingOption();//to get the rounding option of the field
  47.         echo $field->isFormulaField();//to check if the field is a formiula field
  48.         if($field->isFormulaField()){
  49.             echo $field->getFormulaReturnType();//to get the return type of the formula
  50.             echo $field->getFormulaExpression();//to get the formula expression 
  51.         }
  52.         echo $field->isAutoNumberField();//to check if the field is auto numbering
  53.         if($field->isAutoNumberField()){
  54.             echo $field->getPrefix();//to get the prefix value
  55.             echo $field->getSuffix();//to get the suffix value
  56.             echo $field->getStartNumber();//to get the start number 
  57.         }
  58.         echo $field->getDecimalPlace();// to get the decimal place
  59.         echo $field->getJsonType();//to get the json type of the field
  60.        
  61.     }
  62.     $_SERVER['user_email_id']="pravesh.a@zohocorp.com";
  63.     $obj =new Module();
  64.     $obj->getAllLayouts();
  65. ?>

    • Related Articles

    • 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 ...
    • Responses & Exceptions - PHP SDK

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

      The app would be ready to be initialized after defining the OAuth configuration file. Generating self-authorized grant and refresh token For self client apps, the self authorized grant token should be generated from the Zoho Developer Console ...
    • Java SDK Samples

      Module APIs Get List Of Modules - List<ZCRMModule> ZCRMRestClient client = ZCRMRestClient.getInstance(); BulkAPIResponse response = client.getAllModules(); List<ZCRMModule> modules = (List<ZCRMModule>) response.getData(); Meta data APIs Module Meta ...
    • 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 ...