Skip to content

Latest commit

 

History

History
2774 lines (2232 loc) · 112 KB

Migration_Guide.md

File metadata and controls

2774 lines (2232 loc) · 112 KB

Migrating from Zoho CRM PHP SDK 2.x to 3.x

  1. Organization
  2. User
  3. Profiles
  4. Roles
  5. Taxes
  6. Notes
  7. Variables
  8. VariableGroups
  9. Fields
  10. Layouts
  11. CustomViews
  12. RelatedLists
  13. Records
  14. Tags
  15. Attachments
  16. RelatedRecords

Organization

Get OrganizationDetails

  • v2.x.x

    $rest = ZCRMRestClient::getInstance();//to get the rest client
    $orgIns = $rest->getOrganizationDetails()->getData();//to get the organization in form of ZCRMOrganization instance

    sample code

  • v3.x.x

    //Get instance of OrgOperations Class
    $orgOperations = new OrgOperations();
    //Call getOrganization method
    $response = $orgOperations->getOrganization();

    sample code

User

Get Current User

  • v2.x.x

    $rest = ZCRMRestClient::getInstance();//to get the rest client
    $users = $rest->getCurrentUser()->getData();//to get the users in form of ZCRMUser instances array

    sample code

  • v3.x.x

    //Get instance of UsersOperations Class
    $usersOperations = new UsersOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetUsersParam::type(), "CurrentUser"); // AllUsers, ActiveUsers, DeactiveUsers, ConfirmedUsers, NotConfirmedUsers, DeletedUsers, ActiveConfirmedUsers, AdminUsers, ActiveConfirmedAdmins
    $headerInstance = new HeaderMap();
    //Call getUsers method that takes paramInstance as parameter
    $response = $usersOperations->getUsers($paramInstance, $headerInstance);

    sample code

Get User

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $responseIns = $orgIns->getUser("3524033191017");//to get the user

    sample code

  • v3.x.x

    //Get instance of UsersOperations Class
    $usersOperations = new UsersOperations();
    $headerInstance = new HeaderMap();
    //Call getUser method that takes userId as parameter
    $response = $usersOperations->getUser($userId, $headerInstance);

    sample code

Create User

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $user = ZCRMUser::getInstance(NULL, NULL);//to get the user instance
    $user->setLastName("subject");//to set the last name of the user
    $user->setFirstName("test");//to set the first name of the user
    $user->setEmail("[email protected]");//to set the email id of the user
    $role=ZCRMRole::getInstance("{role_id}", "{role_name}");//to get the role
    $user->setRole($role);//to get the role of the user
    $profile=ZCRMProfile::getInstance("{profile_id}", "{profile_name}");//to get the profile
    $user->setProfile($profile);//to set the profile of the user
    $responseIns = $orgIns->createUser($user);//to create the user

    sample code

  • v3.x.x

    //Get instance of UsersOperations Class
    $usersOperations = new UsersOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new RequestWrapper();
    //List of User instances
    $userList = array();
    $userClass = "com\zoho\crm\api\users\User";
    //Get instance of User Class
    $user1 = new $userClass();
    $role = new Role();
    $role->setId("347706126008");
    $user1->setRole($role);
    $user1->setFirstName("TestUser");
    $user1->setEmail("[email protected]");
    $profile = new Profile();
    $profile->setId("347706126014");
    $user1->setProfile($profile);
    $user1->setLastName("12");
    array_push($userList, $user1);
    $request->setUsers($userList);
    //Call createUser method that takes BodyWrapper class instance as parameter
    $response = $usersOperations->createUser($request);

    sample code

Update User

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $user = ZCRMUser::getInstance("{user_id}", "{user_name}");//to get the user instance
    $user->setId("{user_id}");//to set the id of the user
    $user->setFax("321432423423");//to set the fax number of the user
    $user->setMobile("4234234232");//to set the mobile number of the user
    $user->setPhone("2342342342");//to set the phone number of the user
    $user->setStreet("sddsfdsfd");//to set the street name of the user
    $user->setAlias("test");//to set the alias of the user
    $user->setWebsite("www.zoho.com");//to set the website of the user
    $user->setCity("chennai");//to set the city of the user
    $user->setCountry("India");//to set the country of the user
    $user->setState("Tamil nadu");//to set the state of the user
    $user->setZip("6000010");//to set the zip code of the user
    $responseIns = $orgIns->updateUser($user);//to update the user

    sample code

  • v3.x.x

    //Get instance of UsersOperations Class
    $usersOperations = new UsersOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of User instances
    $userList = array();
    $userClass = "com\zoho\crm\api\users\User";
    //Get instance of User Class
    $user1 = new $userClass();
    $role = new Role();
    $role->setId("347706126008");
    $user1->setRole($role);
    $user1->setCountryLocale("en_US");
    array_push($userList, $user1);
    $request->setUsers($userList);
    //Call updateUser method that takes BodyWrapper instance and userId as parameter
    $response = $usersOperations->updateUser($userId, $request);

    sample code

Delete User

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $responseIns = $orgIns->deleteUser("{user_id}");//to delete the user

    sample code

  • v3.x.x

    //Get instance of UsersOperations Class
    $usersOperations = new UsersOperations();
    //Call deleteUser method that takes userId as parameter
    $response = $usersOperations->deleteUser($userId);

    sample code

Profiles

Get All Profiles

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $response = $orgIns->getAllProfiles();//to get the profiles

    sample code

  • v3.x.x

    //Get instance of ProfilesOperations Class
    $profilesOperations = new ProfilesOperations();
    //Call getProfiles method
    $response = $profilesOperations->getProfiles();

    sample code

Get Profile

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $response = $orgIns->getProfile("{profile_id}");//to get the profile

    sample code

  • v3.x.x

    //Get instance of ProfilesOperations Class
    $profilesOperations = new ProfilesOperations();
    //Call getProfile method that takes profileId as parameter
    $response = $profilesOperations->getProfile($profileId);

    sample code

Roles

Get All Roles

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $response = $orgIns->getAllRoles();//to get the roles of the organization
    $roles = $response->getData();//to get the roles in form of array of ZCRMRole instances

    sample code

  • v3.x.x

    //Get instance of RolesOperations Class
    $rolesOperations = new RolesOperations();
    //Call getRoles method
    $response = $rolesOperations->getRoles();

    sample code

Get Role

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $response = $orgIns->getRole("{role_id}");//to get the role of the organization

    sample code

  • v3.x.x

    //Get instance of RolesOperations Class
    $rolesOperations = new RolesOperations();
    //Call getRoles method
    $response = $rolesOperations->getRole($roleId);

    sample code

Taxes

Get Org Taxes

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $orgTaxes = $orgIns->getOrganizationTaxes();

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Call getTaxes method
    $response = $taxesOperations->getTaxes();

    sample code

Get Org Tax Data

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $orgTax = $orgIns->getOrganizationTax("{organization_tax_id}")->getData();

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Call getTax method that takes taxId as parameter
    $response = $taxesOperations->getTax($taxId);

    sample code

Create Org Tax

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $orgTax = ZCRMOrgTax::getInstance("fsdf", NULL);
    $orgTax->setValue("34");
    $orgTaxInstances = array();
    array_push($orgTaxInstances, $orgTax);
    $responseIns = $orgIns->createOrganizationTaxes($orgTaxInstances);

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Tax instances
    $taxList = array();
    $tagClass = 'com\zoho\crm\api\taxes\Tax';
    //Get instance of Tax Class
    $tax1 = new $tagClass();
    $tax1->setName("MyTax22");
    $tax1->setSequenceNumber(2);
    $tax1->setValue(10.0);
    array_push($taxList, $tax1);
    $tax1 = new $tagClass();
    $tax1->setName("MyTax23");
    $tax1->setValue(12.0);
    array_push($taxList, $tax1);
    $request->setTaxes($taxList);
    //Call createTaxes method that takes BodyWrapper class instance as parameter
    $response = $taxesOperations->createTaxes($request);

    sample code

Update Org Tax

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $orgTax = ZCRMOrgTax::getInstance("SalesTax","{org_tax_id}");
    $orgTax->setValue("33");
    $orgTaxInstances = array();
    array_push($orgTaxInstances, $orgTax);
    $responseIns = $orgIns->updateOrganizationTaxes($orgTaxInstances);

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Tax instances
    $taxList = array();
    $taxClass = 'com\zoho\crm\api\taxes\Tax';
    //Get instance of Tax Class
    $tax1 = new $taxClass();
    $tax1->setId("34770616499001");
    $tax1->setName("MyTax1134");
    $tax1->setSequenceNumber(1);
    $tax1->setValue(15.0);
    array_push($taxList, $tax1);
    //Get instance of Tax Class
    $tax1 = new $taxClass();
    $tax1->setId("34770616499002");
    $tax1->setValue(25.0);
    array_push($taxList, $tax1);
    $tax1 = new $taxClass();
    $tax1->setId("3477061339001");
    $tax1->setSequenceNumber(2);s
    array_push($taxList, $tax1);
    $request->setTaxes($taxList);
    //Call updateTaxes method that takes BodyWrapper instance as parameter
    $response = $taxesOperations->updateTaxes($request);

    sample code

Delete Org Taxes

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $responseIns = $orgIns->deleteOrganizationTaxes($orgTaxids);

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($taxIds as $taxId)
    {
        $paramInstance->add(DeleteTaxesParam::ids(), $taxId);
    }
    //Call deleteTaxes method that takes paramInstance as parameter
    $response = $taxesOperations->deleteTaxes($paramInstance);

    sample code

Delete Org Tax

  • v2.x.x

    $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
    $responseIn = $orgIns->deleteOrganizationTax("{org_tax_id}");

    sample code

  • v3.x.x

    //Get instance of TaxesOperations Class
    $taxesOperations = new TaxesOperations();
    //Call deleteTaxes method that takes taxId as parameter
    $response = $taxesOperations->deleteTax($taxId);

    sample code

Notes

Get Notes

  • v2.x.x

    $org = ZCRMOrganization::getInstance();
    /* For VERSION <=2.0.6  $notes = $org->getNotes()->getData(); // to get the notes in form of ZCRMNote instances array */
    $param_map=array("page"=>"20","per_page"=>"200"); // key-value pair containing all the parameters - optional
    $header_map = array("if-modified-since"=>"2019-11-10T15:26:49+05:30"); // key-value pair containing all the headers - optional
    $response = $orgIns->getNotes($param_map,$header_map); // to get all the notes

    sample code

  • v3.x.x

    //Get instance of NotesOperations Class
    $notesOperations = new NotesOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetNotesParam::page(), 1);
    //$paramInstance->add(GetNotesParam::perPage(), 1);
    //Get instance of HeaderMap Class
    $headerInstance = new HeaderMap();
    $headerInstance->add(GetNotesHeader::IfModifiedSince(), date_create("2019-05-07T15:32:24")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
    //Call getNotes method that takes paramInstance and headerInstance as parameters
    $response = $notesOperations->getNotes($paramInstance, $headerInstance);

    sample code

Create Notes

  • v2.x.x

    $org = ZCRMOrganization::getInstance();
    $record = ZCRMRecord::getInstance("Products", "35240333352001");
    $noteIns = ZCRMNote::getInstance($record, NULL); // to get the note instance
    $noteIns->setTitle("Title_API1"); // to set the note title
    $noteIns->setContent("This is test content"); // to set the note content
    $noteIns1 = ZCRMNote::getInstance($record, NULL); // to get another note instance
    $noteIns1->setTitle("Title_API1"); // to set the note title
    $noteIns1->setContent("This is test content");
    $noteInstances=[$noteIns,$noteIns1];
    $responseIn=$org->createNotes($noteInstances);

    sample code

  • v3.x.x

    //Get instance of NotesOperations Class
    $notesOperations = new NotesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $bodyWrapper = new BodyWrapper();
    //List of Note instances
    $notes = array();
    for($i = 1; $i <5; $i++)
    {
        $note->setNoteTitle("Contacted");
        //Set NoteContent of the Note
        $note->setNoteContent("Need to do further tracking");
        //Get instance of Record Class
        $parentRecord = new Record();
        //Set ID of the Record
        $parentRecord->setId("34770615702002");
        //Set ParentId of the Note
        $note->setParentId($parentRecord);
        //Set SeModule of the Record
        $note->setSeModule("Leads");
        //Add Note instance to the list
        array_push($notes, $note);
    }
    //Set the list to notes in BodyWrapper instance
    $bodyWrapper->setData($notes);
    //Call createNotes method that takes BodyWrapper instance as parameter
    $response = $notesOperations->createNotes($bodyWrapper);

    sample code

Delete Notes

  • v2.x.x

    $org = ZCRMOrganization::getInstance();
    $noteIds = ["35240333392002","35240333392001"];
    $responseIn = $org->deleteNotes($noteIds);

    sample code

  • v3.x.x

    //Get instance of NotesOperations Class
    $notesOperations = new NotesOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($notesID as $id)
    {
        $paramInstance->add(DeleteNotesParam::ids(), $id);
    }
    //Call deleteNotes method that takes paramInstance as parameter
    $response = $notesOperations->deleteNotes($paramInstance);

    sample code

Add a Note

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $noteIns = ZCRMNote::getInstance($record, null); // to get the note instance
    $noteIns->setTitle("Title_API1"); // to set the note title
    $noteIns->setContent("This is test content"); // to set the note content
    $responseIns = $record->addNote($noteIns); // to add the note

    sample code

  • v3.x.x

Update a Note

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{moduel_api_name}", "{record_id}"); // To get record instance
    $noteIns = ZCRMNote::getInstance($record, "{note_id}"); // to get the note instance
    $noteIns->setTitle("Title_API1"); // to set the title of the note
    $noteIns->setContent("This is test cooontent"); // to set the content of the note
    $responseIns = $record->updateNote($noteIns); // to update the note

    sample code

  • v3.x.x

    //Get instance of NotesOperations Class
    $notesOperations = new NotesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $bodyWrapper = new BodyWrapper();
    //List of Note instances
    $notes = array();
    $nodeClass = 'com\zoho\crm\api\notes\Note';
    $note = new $nodeClass();
    //Set Note_Title of the Note
    $note->setNoteTitle("Contacted12");
    //Set NoteContent of the Note
    $note->setNoteContent("Need to do further tracking12");
    //Add Note instance to the list
    array_push($notes, $note);
    //Set the list to notes in BodyWrapper instance
    $bodyWrapper->setData($notes);
    //Call updateNote method that takes BodyWrapper instance and noteId as parameter
    $response = $notesOperations->updateNote($noteId,$bodyWrapper);

    sample code

Delete a Note

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $noteIns = ZCRMNote::getInstance($record, "{note_id}"); // to get the note instance
    $responseIns = $record->deleteNote($noteIns); // to delete the note

    sample code

  • v3.x.x

    //Get instance of NotesOperations Class
    $notesOperations = new NotesOperations();
    //Call deleteNotes method that takes BodyWrapper instance as parameter
    $response = $notesOperations->deleteNote($noteID);

    sample code

Variables

Get Variables

  • v2.x.x

    $org_ins = ZCRMOrganization::getInstance();
    $variable_instances = $org_ins->getVariables();

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetVariablesParam::group(), "General");
    //Call getVariables method that takes paramInstance as parameter
    $response = $variablesOperations->getVariables($paramInstance);

    sample code

Create Variables

  • v2.x.x

    $variable_array =array() ;
    $org_ins=ZCRMOrganization::getInstance();
    $variable_ins=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins->setName("v");
    $variable_ins->setType("integer");
    $variable_ins->setValue("2");
    $variable_group = ZCRMVariableGroup::getInstance();
    $variable_group->setId("3524033231001");
    $variable_group->setApiName("General");
    $variable_ins->setVariableGroup($variable_group);
    $variable_ins->setDescription("automated sdk");
    array_push($variable_array,$variable_ins);
    $variable_ins1=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins1->setName("v");
    $variable_ins1->setType("integer");
    $variable_ins1->setValue("2");
    $variable_group = ZCRMVariableGroup::getInstance();
    $variable_group->setId("3524033231001");
    $variable_group->setApiName("General");
    $variable_ins1->setVariableGroup($variable_group);
    $variable_ins1->setDescription("automated sdk");
    array_push($variable_array,$variable_ins1);
    $responseIn=$org_ins->createVariables($variable_array);

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Variable instances
    $variableList = array();
    $variableClass = 'com\zoho\crm\api\variables\Variable';
    //Get instance of Variable Class
    $variable1 = new $variableClass();
    $variable1->setName("asdasd");
    $variable1->setAPIName("sdsd");
    $variableGroup = new VariableGroup();
    $variableGroup->setName("General");
    $variableGroup->setId("347706189001");
    $variable1->setVariableGroup($variableGroup);
    $variable1->setType("integer");
    $variable1->setValue("42");
    $variable1->setDescription("This denotes variable 5 description");
    array_push($variableList, $variable1);
    $variable1 = new $variableClass();
    $variable1->setName("Variable661");
    $variable1->setAPIName("Variable661");
    $variableGroup = new VariableGroup();
    $variableGroup->setName("General");
    $variable1->setVariableGroup($variableGroup);
    $variable1->setType("text");
    $variable1->setValue("H2ello");
    $variable1->setDescription("This denotes variable 6 description");
    array_push($variableList, $variable1);
    $request->setVariables($variableList);
    //Call createVariables method that takes BodyWrapper instance as parameter
    $response = $variablesOperations->createVariables($request);

    sample code

Update Variables

  • v2.x.x

    $variable_array =array() ;
    $org_ins=ZCRMOrganization::getInstance();
    $variable_ins=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins->setId("3524033999002");
    $variable_ins->setName("x");
    $variable_ins->setType("integer");
    $variable_ins->setValue("2");
    $variable_group = ZCRMVariableGroup::getInstance();
    $variable_group->setId("352403301001");
    $variable_group->setApiName("General");
    $variable_ins->setVariableGroup($variable_group);
    $variable_ins->setDescription("automated sdk");
    array_push($variable_array,$variable_ins);
    $variable_ins1=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins1->setName("y");
    $variable_ins1->setId("35240331");
    $variable_ins1->setType("integer");
    $variable_ins1->setValue("2");
    $variable_group = ZCRMVariableGroup::getInstance();
    $variable_group->setId("3524031001");
    $variable_group->setApiName("General");
    $variable_ins1->setVariableGroup($variable_group);
    $variable_ins1->setDescription("automated sdk");
    array_push($variable_array,$variable_ins1);
    $responseIn=$org_ins->updateVariables($variable_array);

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Variable instances
    $variableList = array();
    $variableClass = 'com\zoho\crm\api\variables\Variable';
    //Get instance of Variable Class
    $variable1 = new $variableClass();
    $variable1->setId("34770617444005");
    $variable1->setValue("4763");
    $variable1->setAPIName("er");
    array_push($variableList, $variable1);
    $variable1 = new $variableClass();
    $variable1->setId("34770617444010");
    $variable1->setAPIName("eer");
    $variable1->setDescription("This is a new description");
    array_push($variableList, $variable1);
    $variable1 = new $variableClass();
    $variable1->setId("3477061444012");
    $variable1->setAPIName("re");
    array_push($variableList, $variable1);
    $request->setVariables($variableList);
    //Call updateVariables method that takes BodyWrapper class instance as parameter
    $response = $variablesOperations->updateVariables($request);

    sample code

Get a Variable

  • v2.x.x

    $variable_ins=ZCRMVariable::getInstance();//to get the rest client
    ZCRMVariable::getDescription();
    $variable_ins->setId("35240333124006");
    $group_id = "35240330231001";
    $variable_instance = $variable_ins->getVariable($group_id);

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetVariableByIDParam::group(), "34770613089001");//"General"
    //Call getVariableByGroupId method that takes paramInstance and variableId as parameter
    $response = $variablesOperations->getVariableById($variableId,$paramInstance);

    sample code

Update a Variable

  • v2.x.x

    $variable_ins=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins->setId("3524039002");
    $variable_ins->setValue("3");
    $variable_ins->setDescription("automated sdk");
    $responseIn=$variable_ins->updateVariable();

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Variable instances
    $variableList = array();
    $variableClass = 'com\zoho\crm\api\variables\Variable';
    //Get instance of Variable Class
    $variable1 = new $variableClass();
    $variable1->setAPIName("TestAPIName");
    array_push($variableList, $variable1);
    $request->setVariables($variableList);
    //Call updateVariableById method that takes BodyWrapper instance and variableId as parameter
    $response = $variablesOperations->updateVariableById($variableId,$request);

    sample code

Delete a Variable

  • v2.x.x

    $variable_ins=ZCRMVariable::getInstance();//to get the rest client
    $variable_ins->setId("35240332999002");
    $variable_ins->setValue("3");
    $variable_ins->setDescription("automated sdk");
    $responseIn=$variable_ins->deleteVariable();

    sample code

  • v3.x.x

    //Get instance of VariablesOperations Class
    $variablesOperations = new VariablesOperations();
    //Call deleteVariable method that takes variableId as parameter
    $response = $variablesOperations->deleteVariable($variableId);

    sample code

VariableGroups

Get Variable Groups

  • v2.x.x

    $org_ins = ZCRMOrganization::getInstance();//to get the rest client
    $variable_group_instances = $org_ins->getVariableGroups();

    sample code

  • v3.x.x

    //Get instance of VariableGroupsOperations Class
    $variableGroupsOperations = new VariableGroupsOperations();
    //Call getVariableGroups method
    $response = $variableGroupsOperations->getVariableGroups();

    sample code

Get a Variable Group

  • v2.x.x

    $variable_group_ins=ZCRMVariableGroup::getInstance();//to get the rest client
    $variable_group_ins->setId("3524033000000231001");
    $variable_group_instance = $variable_group_ins->getVariableGroup();

    sample code

  • v3.x.x

    //Get instance of VariableGroupsOperations Class
    $variableGroupsOperations = new VariableGroupsOperations();
    //Call getVariableGroupById method that takes variableGroupId as parameter
    $response = $variableGroupsOperations->getVariableGroupById($variableGroupId);

    sample code

Fields

Get All Fields

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getAllFields(); // to get the field

    sample code

  • v3.x.x

    //Get instance of FieldsOperations Class that takes moduleAPIName as parameter
    $fieldOperations = new FieldsOperations($moduleAPIName);
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    // $paramInstance->add(GetFieldsParam::type(), "Unused");
    //Call getFields method that takes paramInstance as parameter
    $response = $fieldOperations->getFields($paramInstance);

    sample code

Get Field Details

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name"); // To get module instance
    $response = $moduleIns->getFieldDetails("{field_id}"); // to get the field

    sample code

  • v3.x.x

    //Get instance of FieldsOperations Class that takes moduleAPIName as parameter
    $fieldOperations = new FieldsOperations($moduleAPIName);
    //Call getField method which takes fieldId as parameter
    $response = $fieldOperations->getField($fieldId);

sample code

Layouts

Get All Layouts

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getAllLayouts(); // to get all the layout

    sample code

  • v3.x.x

    //Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
    $layoutsOperations = new LayoutsOperations($moduleAPIName);
    //Call getLayouts method
    $response = $layoutsOperations->getLayouts();
        ```
    
    [sample code](https://www.zoho.com/crm/developer/docs/php-sdk/v3/layouts-samples.html?src=get_layouts)

Get Layout Details

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getLayoutDetails("35240331055"); // to get the layout

    sample code

  • v3.x.x

    //Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
    $layoutsOperations = new LayoutsOperations($moduleAPIName);
    //Call getLayouts method
    $response = $layoutsOperations->getLayout($layoutId);

    sample code

CustomViews

Get All CustomViews

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    /* For VERSION <=2.0.6
    $response = $moduleIns->getAllCustomViews(); // to get all the custom views*/
    $param_map = array("page"=>"5","per_page"=>"10");//parameters to be passed
    $response = $moduleIns->getAllCustomViews($param_map); // to get all the custom views /$param_map - optional

    sample code

  • v3.x.x

    //Get instance of CustomViewOperations Class that takes moduleAPIName as parameter
    $customViewsOperations = new CustomViewsOperations($moduleAPIName);
    //Call getCustomViews method
    $response = $customViewsOperations->getCustomViews();

    sample code

Get Custom View Details

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getCustomView("{custom_view_id}"); // to get the custom view

    sample code

  • v3.x.x

    //Get instance of CustomViewOperations Class that takes moduleAPIName as parameter
    $customViewsOperations = new CustomViewsOperations($moduleAPIName);
    //Call getCustomView method that takes customViewId as parameter
    $response = $customViewsOperations->getCustomView($customViewId);

    sample code

RelatedLists

Get All Related Lists

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getAllRelatedLists(); // to get all the related lists

    sample code

  • v3.x.x

    //Get instance of RelatedListsOperations Class that takes moduleAPIName as parameter
    $relatedListsOperations = new RelatedListsOperations($moduleAPIName);
    //Call getRelatedLists method
    $response = $relatedListsOperations->getRelatedLists();

    sample code

Get Related List Details

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $response = $moduleIns->getRelatedListDetails("{related_list_id}"); // to get the related list

    sample code

    • v3.x.x

      //Get instance of RelatedListsOperations Class that takes moduleAPIName as parameter
      $relatedListsOperations = new RelatedListsOperations($moduleAPIName);
      //Call getRelatedLists method which takes relatedListId as parameter
      $response = $relatedListsOperations->getRelatedList($relatedListId);

    sample code

Records

Get List of Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    /* For VERSION <=2.0.6 $response = $moduleIns->getRecords(null, null, null, 1, 100, null); // to get the records(parameter - custom_view_id,field_api_name,sort_order,customHeaders is optional and can be given null if not required), customheader is a keyvalue pair for eg("if-modified-since"=>"2008-09-15T15:53:00")*/
    $param_map=array("page"=>10,"per_page"=>10); // key-value pair containing all the parameters - optional
    $header_map = array("if-modified-since"=>"2019-11-15T15:26:49+05:30"); // key-value pair containing all the headers - optional
    $response = $moduleIns->getRecords($param_map,$header_map); // to get the records($param_map - parameter map,$header_map - header map

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class that takes moduleAPIName as parameter
    $recordOperations = new RecordOperations();
    $paramInstance = new ParameterMap();
    // $paramInstance->add(GetRecordsParam::approved(), "true");
    // $paramInstance->add(GetRecordsParam::converted(), "1234");
    // $paramInstance->add(GetRecordsParam::cvid(), "347706189005");
    // $ids = array("34770615623115", "34770614352001");
    // foreach($ids as $id)
    // {
    // 	$paramInstance->add(GetRecordsParam::ids(), $id);
    // }
    // $paramInstance->add(GetRecordsParam::uid(), "34770615181008");
    // $fieldNames = array("Last_Name", "City");
    // foreach($fieldNames as $fieldName)
    // {
        $paramInstance->add(GetRecordsParam::fields(), "id");
    // }
    // $paramInstance->add(GetRecordsParam::sortBy(), "Email");
    // $paramInstance->add(GetRecordsParam::sortOrder(), "desc");
    $paramInstance->add(GetRecordsParam::page(), 1);
    $paramInstance->add(GetRecordsParam::perPage(), 3);
    $startdatetime = date_create("2020-06-27T15:10:00+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    // $paramInstance->add(GetRecordsParam::startDateTime(), $startdatetime);
    // $enddatetime = date_create("2020-06-29T15:10:00+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    // $paramInstance->add(GetRecordsParam::endDateTime(), $enddatetime);
    // $paramInstance->add(GetRecordsParam::territoryId(), "34770613051357");
    // $paramInstance->add(GetRecordsParam::includeChild(), true);
    $headerInstance = new HeaderMap();
    // $datetime = date_create("2021-02-26T15:28:34+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    // $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $datetime);
    //Call getRecords method
    $response = $recordOperations->getRecords($moduleAPIName,$paramInstance, $headerInstance);

    sample code

Get a Record

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
    $param_map = array("fields"=>"Company,Last_Name"); // key-value pair containing all the params - optional
    $header_map = array("header_name"=>"header_value"); // key-value pair containing all the headers - optional
    $response = $moduleIns->getRecord("{record_id}",$param_map,$header_map); // To get module record

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    // $paramInstance->add(GetRecordParam::approved(), "false");
    // $paramInstance->add(GetRecordParam::converted(), "false");
    // $fieldNames = array("Deal_Name", "Company");
    // foreach($fieldNames as $fieldName)
    // {
    // $paramInstance->add(GetRecordParam::fields(), $fieldName);
    // }
    // $startdatetime = date_create("2020-06-27T15:10:00");
    // $paramInstance->add(GetRecordParam::startDateTime(), $startdatetime);
    // $enddatetime = date_create("2020-06-29T15:10:00");
    // $paramInstance->add(GetRecordParam::endDateTime(), $enddatetime);
    // $paramInstance->add(GetRecordParam::territoryId(), "34770613051357");
    // $paramInstance->add(GetRecordParam::includeChild(), true);
    $headerInstance = new HeaderMap();
    // $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    // $headerInstance->add(GetRecordHeader::IfModifiedSince(), $ifmodifiedsince);
    //Call getRecord method that takes paramInstance, moduleAPIName and recordID as parameter
    $response = $recordOperations->getRecord( $recordId,$moduleAPIName,$paramInstance, $headerInstance);

    sample code

Search Records

  • v2.x.x

    • Search Records by Word

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
      /* For VERSION <=2.0.6  $searchWord="word_to_search_for";//word to search for
      $page=1;//page number
      $perPage=200;//records per page
      $response = $moduleIns->searchRecords($searchWord, $page , $perPage ); // To get module records// $searchWord word to be searched// $page to get the list of records from the respective pages. Default value for page is 1.// $perPage To get the list of records available per page. Default value for per page is 200.*/
      $searchWord = "automated";//word to search for
      $param_map = array("page"=>1,"per_page"=>1); // key-value pair containing all the parameters
      $response = $moduleIns->searchRecordsByWord($searchWord,$param_map) ;// To get module records// $searchWord word to be searched// $param_map-parameters key-value pair - optional
      $records = $response->getData(); // To get response data

      sample code

    • Search Records by Phone

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
      $phone = 313213;//phone number to search for
      /*For VERSION searchRecordsByPhone($phone, $page, $perPage); // To get module records// $searchWord word to be searched// $page to get the list of records from the respective pages. Default value for page is 1.// $perPage To get the list of records available per page. Default value for per page is 200.*/
      $param_map = array("page"=>1,"per_page"=>1); // key-value pair containing all the parameters
      $response = $moduleIns->searchRecordsByPhone($phone,$param_map) ;// To get module records// $phone phone to be searched// $param_map-parameters key-value pair - optional
      $records = $response->getData(); // To get response data

      sample code

    • Search Records by Email

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
      /* For VERSION <=2.0.6 $email="{email_id}";//email id  to search for
      $page=1;//page number
      $perPage=200;//records per page
      $response = $moduleIns->searchRecordsByEmail($email, $page, $perPage); // To get module records//$searchWord word to be searched//$page to get the list of records from the respective pages. Default value for page is 1.//$perPage To get the list of records available per page. Default value for per page is 200.*/
      $email = "email_id";//email id  to search for
      $param_map=array("page"=>1,"per_page"=>1); // key-value pair containing all the parameters
      $response = $moduleIns->searchRecordsByEmail($email,$param_map) ;// To get module records// $email email id  to search for// $param_map-parameters key-value pair - optional

      sample code

    • Search Records by Criteria

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // To get module instance
      $criteria = "criteria";//criteria to search for
      /* For VERSION <=2.0.6  $page=5;//page number
      $perPage=200;//records per page
      $response = $moduleIns->searchRecordsByCriteria($criteria, $page, $perPage); // To get module records//string $searchWord word to be searched//number $page to get the list of records from the respective pages. Default value for page is 1.//number $perPage To get the list of records available per page. Default value for per page is 200.*/
          $param_map=array("page"=>1,"per_page"=>1); // key-value pair containing all the parameters
      $response = $moduleIns->searchRecordsByCriteria($criteria,$param_map) ;// To get module records// $criteria to search for  to search for// $param_map-parameters key-value pair - optional

      sample code

  • v3.x.x

    //example, moduleAPIName = "Leads";
    //Get instance of RecordOperations Class that takes moduleAPIName as parameter
    $recordOperations = new RecordOperations();
    $paramInstance = new ParameterMap();
    $paramInstance->add(SearchRecordsParam::criteria(), "((Last_Name:starts_with:Last Name) or (Company:starts_with:fasf\\(123\\) K))");
    $paramInstance->add(SearchRecordsParam::email(), "[email protected]");
    $paramInstance->add(SearchRecordsParam::phone(), "234567890");
    $paramInstance->add(SearchRecordsParam::word(), "First Name Last Name");
    $paramInstance->add(SearchRecordsParam::converted(), "both");
    $paramInstance->add(SearchRecordsParam::approved(), "both");
    $paramInstance->add(SearchRecordsParam::page(), 1);
    $paramInstance->add(SearchRecordsParam::perPage(), 2);
    //Call getRecords method
    $response = $recordOperations->searchRecords($moduleAPIName,$paramInstance);

    sample code

Update Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the instance of the module
    $inventoryRecords = array();
    /**
        * Following methods are being used only by same Inventory only  *
        */
    $record = ZCRMRecord::getInstance("{module_api_name}", "{record_id}"); // to get the instance of the record
    $record->setFieldValue("Subject", "Invoice3"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record->setFieldValue("Account_Name", "{account_id}");
    $lineItem = ZCRMInventoryLineItem::getInstance("{line_item_id}"); // To get ZCRMInventoryLineItem instance
    $lineItem->setDescription("Product_description"); // To set line item description
    $lineItem->setDiscount(20); // To set line item discount
    $lineItem->setListPrice(3412); // To set line item list price
    
    $taxInstance1 = ZCRMTax::getInstance("{tax_name}"); // to get the tax instance
    $taxInstance1->setPercentage(20); // to set the tax percentage
    $taxInstance1->setValue(50); // to set the tax value
    $lineItem->addLineTax($taxInstance1); // to add the tax to the line item
    
    $lineItem->setQuantity(101); // To set product quantity to this line item
    $record->addLineItem($lineItem); // to add the line item to the record of invoice
    
    array_push($inventoryRecords, $record); // pushing the record to the array
    
    $record2 = ZCRMRecord::getInstance("{module_api_name}", "{record_id}"); // to get the instance of the record
    $record2->setFieldValue("Subject", "Invoice3"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record2->setFieldValue("Account_Name", "{account_id}");
    $lineItem = ZCRMInventoryLineItem::getInstance("{line_item_id}"); // To get ZCRMInventoryLineItem instance
    $lineItem->setDescription("Product_description"); // To set line item description
    $lineItem->setDiscount(20); // To set line item discount
    $lineItem->setListPrice(3412); // To set line item list price
    
    $taxInstance1 = ZCRMTax::getInstance("{tax_name}"); // to get the tax instance
    $taxInstance1->setPercentage(20); // to set the tax percentage
    $taxInstance1->setValue(50); // to set the tax value
    $lineItem->addLineTax($taxInstance1); // to add the tax to the line item
    
    $lineItem->setQuantity(101); // To set product quantity to this line item
    $record2->addLineItem($lineItem); // to add the line item to the record of invoice
    
    array_push($inventoryRecords, $record2); // pushing the record to the array
    
    /**
        * for Price books module only
        */
    $pricebookRecords = array();
    
    $record = ZCRMRecord::getInstance("Price_Books", "price_book_id"); // to get the price book record
    $record->setFieldValue("Pricing_Details", json_decode('[ { "to_range": 5, "discount": 0, "from_range": 1 }, { "to_range": 11, "discount": 1, "from_range": 6 }, { "to_range": 17, "discount": 2, "from_range": 12 }, { "to_range": 23, "discount": 3, "from_range": 18 }, { "to_range": 29, "discount": 4, "from_range": 24 } ]', true)); // setting the discount , range of the pricebook record
    $record->setFieldValue("Pricing_Model", "Flat"); // setting the price book model
    array_push($pricebookRecords, $record); // pushing the record to the array
    
    
    $trigger=array();//triggers to include
    $responseIn = $moduleIns->updateRecords($inventoryRecords,$trigger); // updating the records.$trigger is optional , to update price book records$pricebookRecords can be used in the place of $inventoryRecords

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Record instances
    $records = array();
    $recordClass = 'com\zoho\crm\api\record\Record';
    //Get instance of Record Class
    $record1 = new $recordClass();
    $record1->setId("34770616606002");
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $field = new Field("");
    $record1->addFieldValue(Leads::City(), "City");
    $record1->addFieldValue(Leads::LastName(), "Last Name");
    $record1->addFieldValue(Leads::FirstName(), "First Name");
    $record1->addFieldValue(Leads::Company(), "KKRNP");
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record1->addKeyValue("Custom_field", "Value");
    $record1->addKeyValue("Custom_field_2", "value");
    //Add Record instance to the list
    // array_push($records, $record1);
    //Get instance of Record Class
    $record2 = new $recordClass();
    $record2->setId("34770616603294");
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $record2->addFieldValue(Leads::City(), "City");
    $record2->addFieldValue(Leads::LastName(), "Last Name");
    $record2->addFieldValue(Leads::FirstName(), "First Name");
    $record2->addFieldValue(Leads::Company(), "KKRNP");
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record2->addKeyValue("Custom_field", "Value");
    $record2->addKeyValue("Custom_field_2", "value");
    //Add Record instance to the list
    // array_push($records, $record2);
    //Set the list to Records in BodyWrapper instance
    $request->setData($records);
    $trigger = array("approval", "workflow", "blueprint");
    $request->setTrigger($trigger);
    //Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameter.
    $response = $recordOperations->updateRecords($moduleAPIName, $request);

    sample code

Create Records

  • v2.x.x

    $moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); //to get the instance of the module
    $records=array();
    $record=ZCRMRecord::getInstance("{module_api_name}",null);  //To get ZCRMRecord instance
    $record->setFieldValue("Subject","Invoice"); //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record->setFieldValue("Account_Name","{account_id}"); //This function is for Invoices module
    /** Following methods are being used only by Inventory modules **/
    
    $lineItem=ZCRMInventoryLineItem::getInstance(null);  //To get ZCRMInventoryLineItem instance
    $lineItem->setDescription("Product_description");  //To set line item description
    $lineItem ->setDiscount(5);  //To set line item discount
    $lineItem->setListPrice(100);  //To set line item list price
    
    $taxInstance1=ZCRMTax::getInstance("{tax_name}");  //To get ZCRMTax instance
    $taxInstance1->setPercentage(2);  //To set tax percentage
    $taxInstance1->setValue(50);  //To set tax value
    $lineItem->addLineTax($taxInstance1);  //To set line tax to line item
    
    $taxInstance1=ZCRMTax::getInstance("{tax_name}"); //to get the tax instance
    $taxInstance1->setPercentage(12); //to set the tax percentage
    $taxInstance1->setValue(50); //to set the tax value
    $lineItem->addLineTax($taxInstance1); //to add the tax to line item
    
    $lineItem->setProduct(ZCRMRecord::getInstance("{module_api_name}","{record_id}"));  //To set product to line item
    $lineItem->setQuantity(100);  //To set product quantity to this line item
    
    $record->addLineItem($lineItem);   //to add the line item to the record
    
    
    array_push($records, $record); // pushing the record to the array.
    $trigger = array();//triggers to include
    $lar_id = {"lead_assignment_rule_id"};//lead assignment rule id
    $responseIn = $moduleIns->createRecords($records, $trigger,$lar_id); // updating the records.$trigger,$lar_id are optional

sample code

  • v3.x.x

    //Get instance of RecordOperations Class that takes moduleAPIName as parameter
    $recordOperations = new RecordOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $bodyWrapper = new BodyWrapper();
    //List of Record instances
    $records = array();
    $recordClass = 'com\zoho\crm\api\record\Record';
    //Get instance of Record Class
    $record1 = new $recordClass();
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $field = new Field("");
    // $record1->addFieldValue(Leads::City(), "City");
    $record1->addFieldValue(Leads::LastName(), "FROm PHP");
    // $record1->addFieldValue(Leads::FirstName(), "First Name");
    // $record1->addFieldValue(Leads::Company(), "KKRNP");
    // $record1->addFieldValue(Vendors::VendorName(), "Vendor Name");
    // $record1->addFieldValue(Deals::Stage(), new Choice("Clo"));
    // $record1->addFieldValue(Deals::DealName(), "deal_name");
    // $record1->addFieldValue(Deals::Description(), "deals description");
    // $record1->addFieldValue(Deals::ClosingDate(), new \DateTime("2021-06-02"));
    // $record1->addFieldValue(Deals::Amount(), 50.7);
    // $record1->addFieldValue(Campaigns::CampaignName(), "Campaign_Name");
    // $record1->addFieldValue(Solutions::SolutionTitle(), "Solution_Title");
    $record1->addFieldValue(Accounts::AccountName(), "Account_Name");
    // $record1->addFieldValue(Cases::CaseOrigin(), new Choice("AutomatedSDK"));
    // $record1->addFieldValue(Cases::Status(), new Choice("AutomatedSDK"));
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    // $record1->addKeyValue("Custom_field", "Value");
    // $record1->addKeyValue("Custom_field_2", "value");
    $record1->addKeyValue("Date_1", new \DateTime('2021-03-08'));
    $record1->addKeyValue("Date_Time_2", date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
    // $record1->addKeyValue("Subject", "From PHP");
    // $taxName = array(new Choice("Vat"), new Choice("Sales Tax"));
    // $record1->addKeyValue("Tax", $taxName);
    // $record1->addKeyValue("Product_Name", "AutomatedSDK");
    // $fileDetails = array();
    // $fileDetail1 = new FileDetails();
    // $fileDetail1->setFileId("ae9c7cefa30f3c0dee629");
    // array_push($fileDetails, $fileDetail1);
    // $fileDetail2 = new FileDetails();
    // $fileDetail2->setFileId("ae9c7cefa418aec1d92ec8454d7");
    // array_push($fileDetails, $fileDetail2);
    // $fileDetail3 = new FileDetails();
    // $fileDetail3->setFileId("ae9c7cefa418aec1d6aee6eb");
    // array_push($fileDetails, $fileDetail3);
    // $record1->addKeyValue("File_Upload", $fileDetails);
    // /** Following methods are being used only by Inventory modules */
    // $vendorName = new $recordClass();
    // $record1->addFieldValue(Vendors::id(), "34770617247001");
    // $record1->addFieldValue(Purchase_Orders::VendorName(), $vendorName);
    // $dealName = new $recordClass();
    // $dealName->addFieldValue(Deals::id(), "34770614995070");
    // $record1->addFieldValue(Sales_Orders::DealName(), $dealName);
    // $contactName = new $recordClass();
    // $contactName->addFieldValue(Contacts::id(), "34770614977055");
    // $record1->addFieldValue(Purchase_Orders::ContactName(), $contactName);
    // $accountName = new $recordClass();
    // $accountName->addKeyValue("name", "automatedAccount");
    // $record1->addFieldValue(Quotes::AccountName(), $accountName);
    // $record1->addKeyValue("Discount", 10.5);
    // $inventoryLineItemList = array();
    // $inventoryLineItem = new InventoryLineItems();
    // $lineItemProduct = new LineItemProduct();
    // $lineItemProduct->setId("34770615356009");
    // $inventoryLineItem->setProduct($lineItemProduct);
    // $inventoryLineItem->setQuantity(1.5);
    // $inventoryLineItem->setProductDescription("productDescription");
    // $inventoryLineItem->setListPrice(10.0);
    // $inventoryLineItem->setDiscount("5.0");
    // $inventoryLineItem->setDiscount("5.25%");
    // $productLineTaxes = array();
    // $productLineTax = new LineTax();
    // $productLineTax->setName("Sales Tax");
    // $productLineTax->setPercentage(20.0);
    // array_push($productLineTaxes, $productLineTax);
    // $inventoryLineItem->setLineTax($productLineTaxes);
    // array_push($inventoryLineItemList, $inventoryLineItem);
    // $record1->addKeyValue("Product_Details", $inventoryLineItemList);
    // $lineTaxes = array();
    // $lineTax = new LineTax();
    // $lineTax->setName("Sales Tax");
    // $lineTax->setPercentage(20.0);
    // array_push($lineTaxes,$lineTax);
    // $record1->addKeyValue('$line_tax', $lineTaxes);
        /** End Inventory **/
    /** Following methods are being used only by Activity modules */
    // Tasks,Calls,Events
    // $record1->addFieldValue(Tasks::Description(), "Test Task");
    // $record1->addKeyValue("Currency",new Choice("INR"));
    // $remindAt = new RemindAt();
    // $remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00.05:30");
    // $record1->addFieldValue(Tasks::RemindAt(), $remindAt);
    // $whoId = new $recordClass();
    // $whoId->setId("34770614977055");
    // $record1->addFieldValue(Tasks::WhoId(), $whoId);
    // $record1->addFieldValue(Tasks::Status(),new Choice("Waiting for input"));
    // $record1->addFieldValue(Tasks::DueDate(), new \DateTime('2021-03-08'));
    // $record1->addFieldValue(Tasks::Priority(),new Choice("High"));
    // $record1->addKeyValue('$se_module', "Accounts");
    // $whatId = new $recordClass();
    // $whatId->setId("3477061207118");
    // $record1->addFieldValue(Tasks::WhatId(), $whatId);
    /** Recurring Activity can be provided in any activity module*/
    // $recurringActivity = new RecurringActivity();
    // $recurringActivity->setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
    // $record1->addFieldValue(Events::RecurringActivity(), $recurringActivity);
    // Events
    // $record1->addFieldValue(Events::Description(), "Test Events");
    $startdatetime = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    $record1->addFieldValue(Events::StartDateTime(), $startdatetime);
    // $participants = array();
    // $participant1 = new Participants();
    // $participant1->setParticipant("[email protected]");
    // $participant1->setType("email");
    // $participant1->setId("34770615902017");
    // array_push($participants, $participant1);
    // $participant2 = new Participants();
    // $participant2->addKeyValue("participant", "34770615844006");
    // $participant2->addKeyValue("type", "lead");
    // array_push($participants, $participant2);
    // $record1->addFieldValue(Events::Participants(), $participants);
    // $record1->addKeyValue('$send_notification', true);
    $record1->addFieldValue(Events::EventTitle(), "From PHP");
    $enddatetime = date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    $record1->addFieldValue(Events::EndDateTime(), $enddatetime);
    // $remindAt = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    // $record1->addFieldValue(Events::RemindAt(), $remindAt);
    // $record1->addFieldValue(Events::CheckInStatus(), "PLANNED");
    // $remindAt = new RemindAt();
    // $remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-23T12:30:00+05:30");
    // $record1->addFieldValue(Tasks::RemindAt(), $remindAt);
    // $record1->addKeyValue('$se_module', "Leads");
    // $whatId = new $recordClass();
    // $whatId->setId("34770614381002");
    // $record1->addFieldValue(Events::WhatId(), $whatId);
    // $record1->addFieldValue(Tasks::WhatId(), $whatId);
    // $record1->addFieldValue(Calls::CallType(), new Choice("Outbound"));
    // $record1->addFieldValue(Calls::CallStartTime(), date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
    /** End Activity **/
    /** Following methods are being used only by Price_Books modules */
    // $pricingDetails = array();
    // $pricingDetail1 = new PricingDetails();
    // $pricingDetail1->setFromRange(1.0);
    // $pricingDetail1->setToRange(5.0);
    // $pricingDetail1->setDiscount(2.0);
    // array_push($pricingDetails, $pricingDetail1);
    // $pricingDetail2 = new PricingDetails();
    // $pricingDetail2->addKeyValue("from_range", 6.0);
    // $pricingDetail2->addKeyValue("to_range", 11.0);
    // $pricingDetail2->addKeyValue("discount", 3.0);
    // array_push($pricingDetails, $pricingDetail2);
    // $record1->addFieldValue(Price_Books::PricingDetails(), $pricingDetails);
    // $record1->addKeyValue("Email", "[email protected]");
    // $record1->addFieldValue(Price_Books::Description(), "TEST");
    // $record1->addFieldValue(Price_Books::PriceBookName(), "book_name");
    // $record1->addFieldValue(Price_Books::PricingModel(), new Choice("Flat"));
    $tagList = array();
    $tag = new Tag();
    $tag->setName("Testtask");
    array_push($tagList, $tag);
    //Set the list to Tags in Record instance
    $record1->setTag($tagList);
    //Add Record instance to the list
    // array_push($records, $record1);
    //Set the list to Records in BodyWrapper instance
    $bodyWrapper->setData($records);
    $trigger = array("approval", "workflow", "blueprint");
    $bodyWrapper->setTrigger($trigger);
    //bodyWrapper.setLarId("347706187515");
    //Call createRecords method that takes BodyWrapper instance as parameter.
    $response = $recordOperations->createRecords($moduleAPIName,$bodyWrapper);

    sample code

Delete Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the instance of the module
    $recordids = array(
        "{record_id}",
        "{record_id}"
    ); // to create an array of record ids
    $responseIn = $moduleIns->deleteRecords($recordids); // to delete the recordss

    sample code

  • v3.x.x

    //API Name of the module to update record
    //$moduleAPIName = "Leads";
    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($recordIds as $id)
    {
        $paramInstance->add(DeleteRecordsParam::ids(), $id);
    }
    // $paramInstance->add(DeleteRecordsParam::wfTrigger(), "true");
    //Call deleteRecord method that takes ModuleAPIName and recordId as parameter.
    $response = $recordOperations->deleteRecords($moduleAPIName,$paramInstance);

    sample code

Get Deleted Records

  • v2.x.x

    • Get List of Deleted Records

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the instance of the module
      /*For VERSION getAllDeletedRecords()->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances */
      $param_map = array("page"=>"20","per_page"=>"200"); // key-value pair containing all the parameters - optional
      $header_map = array("if-modified-since"=>"2019-11-10T15:26:49+05:30"); // key-value pair containing all the headers - optional
      $trashRecords = $moduleIns->getAllDeletedRecords($param_map,$header_map)->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances/$param_map - parameter map, $header_map - header_map

      sample code

    • Get Records from Recycle Bin

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the instance of the module
      /* For VERSION <=2.0.6 $trashRecords = $moduleIns->getRecycleBinRecords()->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances*/
          $param_map = array("page"=>"20","per_page"=>"200"); // key-value pair containing all the parameters - optional
      $header_map = array("if-modified-since"=>"2019-11-10T15:26:49+05:30"); // key-value pair containing all the headers - optional
      $trashRecords = $moduleIns->getRecycleBinRecords($param_map,$header_map)->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances/$param_map - parameter map, $header_map - header_map

      sample code

    • Get List of Permanently Deleted Records

      $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("Leads"); // to get the instance of the module
      /* For VERSION <=2.0.6 $trashRecords = $moduleIns->getPermanentlyDeletedRecords()->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances*/
          $param_map = array("page"=>"20","per_page"=>"200"); // key-value pair containing all the parameters - optional
      $header_map = array("if-modified-since"=>"2019-11-10T15:26:49+05:30"); // key-value pair containing all the headers - optional
      $trashRecords = $moduleIns->getPermanentlyDeletedRecords($param_map,$header_map)->getData(); // to get the trashrecords inform of ZCRMTrashRecord array instances/$param_map - parameter map, $header_map - header_map

      sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetDeletedRecordsParam::type(), "recycle");//all, recycle, permanent
    // $paramInstance->add(GetDeletedRecordsParam::page(), 1);
    // $paramInstance->add(GetDeletedRecordsParam::perPage(), 2);
    //Get instance of HeaderMap Class
    $headerInstance = new HeaderMap();
    $ifModifiedSince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
    $headerInstance->add(GetDeletedRecordsHeader::IfModifiedSince(), $ifModifiedSince);
    //Call getDeletedRecords method that takes paramInstance, headerInstance and moduleAPIName as parameter
    $response = $recordOperations->getDeletedRecords($moduleAPIName, $paramInstance, $headerInstance);

    sample code

Upsert Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{Module_api_name"); // to get the instance of the module
    $records = array();
    /**
        * Following methods are being used only by Inventory modules *
        */
    $record = ZCRMRecord::getInstance("{record_id}", null); // to get the instance of the record
    $record->setFieldValue("Company", "Invoisdsddsdce3"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record->setFieldValue("Email", "[email protected]");
    $record->setFieldValue("Last_Name", "aaddasd");
    array_push($records, $record); // pushing the record to the array
    $duplicate_check_fields = array('Company');
    $lar_id = "{lar_id}";
    $trigger = array();//trigger to include
    $responseIn = $moduleIns->upsertRecords($records, null, $lar_id, $duplicate_check_fields); // updating the records.

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class that takes moduleAPIName as parameter
    $recordOperations = new RecordOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Record instances
    $records = array();
    $recordClass = 'com\zoho\crm\api\record\Record';
    //Get instance of Record Class
    $record1 = new $recordClass();
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $field = new Field("");
    $record1->addFieldValue(Leads::City(), "City");
    // $record1->addFieldValue(Leads::LastName(), "Last Name");
    $record1->addFieldValue(Leads::FirstName(), "First Name");
    $record1->addFieldValue(Leads::Company(), "Company1");
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record1->addKeyValue("Custom_field", "Value");
    $record1->addKeyValue("Custom_field_2", "value");
    //Add Record instance to the list
    array_push($records, $record1);
    //Get instance of Record Class
    $record2 = new $recordClass();
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $record2->addFieldValue(Leads::City(), "City");
    // $record2->addFieldValue(Leads::LastName(), "Last Name");
    $record2->addFieldValue(Leads::FirstName(), "First Name");
    $record2->addFieldValue(Leads::Company(), "Company12");
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record2->addKeyValue("Custom_field", "Value");
    $record2->addKeyValue("Custom_field_2", "value");
    //Add Record instance to the list
    array_push($records, $record2);
    $duplicateCheckFields = array("City", "Last_Name", "First_Name");
    $request->setDuplicateCheckFields($duplicateCheckFields);
    //Set the list to Records in BodyWrapper instance
    $request->setData($records);
    //Call createRecords method that takes BodyWrapper instance as parameter.
    $response = $recordOperations->upsertRecords($moduleAPIName, $request);

    sample code

Mass Update Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("leads"); // to get the instance of the module
    $entityIds = array(
        "{record_id}"
    ); // array of entity ids
    $responseIn = $moduleIns->massUpdateRecords($entityIds, "{field_api_name}", "{value to update}"); // to update the field api name with corresponding field value for the entities

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of MassUpdateBodyWrapper Class that will contain the request body
    $request = new MassUpdateBodyWrapper();
    //List of Record instances
    $records = array();
    $recordClass = 'com\zoho\crm\api\record\Record';
    //Get instance of Record Class
    $record1 = new $recordClass();
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record1->addKeyValue("City", "Value");
    //Add Record instance to the list
    array_push($records, $record1);
    //Set the list to Records in BodyWrapper instance
    $request->setData($records);
    $request->setCvid("347706187501");
    // $ids = array("34770616603276");
    // $request->setIds($ids);
    // $territory = new Territory();
    // $territory->setId("34770613051357");
    // $territory->setIncludeChild(true);
    // $request->setTerritory($territory);
    $request->setOverWrite(true);
    //Call massUpdateRecords method that takes BodyWrapper instance, ModuleAPIName as parameter.
    $response = $recordOperations->massUpdateRecords($moduleAPIName, $request);

    sample code

Create a Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $record->setFieldValue("Subject", "test2312"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record->setFieldValue("Account_Name", "35240331052013"); // Account Name can be given for a new account, account_id is not mandatory in that case
    /**
        * Following methods are being used only by Inventory modules *
        */
    
    $lineItem = ZCRMInventoryLineItem::getInstance(null); // To get ZCRMInventoryLineItem instance
    $lineItem->setDescription("Product_description"); // To set line item description
    $lineItem->setDiscount(5); // To set line item discount
    $lineItem->setListPrice(100); // To set line item list price
    
    $taxInstance1 = ZCRMTax::getInstance("org"); // To get ZCRMTax instance
    $taxInstance1->setPercentage(2); // To set tax percentage
    $taxInstance1->setValue(50); // To set tax value
    $lineItem->addLineTax($taxInstance1); // To set line tax to line item
    
    $taxInstance1 = ZCRMTax::getInstance("org");
    $taxInstance1->setPercentage(12);
    $taxInstance1->setValue(50);
    $lineItem->addLineTax($taxInstance1);
    
    $lineItem->setProduct(ZCRMRecord::getInstance("Products", "{product_id}")); // To set product to line item
    $lineItem->setQuantity(100); // To set product quantity to this line item
    
    $record->addLineItem($lineItem);
    $trigger=array();//triggers to include
    $lar_id="{lar_id}";//lead assignment rule id
    $responseIns = $record->create($trigger,$lar_id);//$trigger , $larid optional

    sample code

  • v3.x.x

Update a Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    /**
        * only for inventory module *
        */
    $record->setFieldValue("Subject", "test2312"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
    $record->setFieldValue("Account_Name", "{account_id}"); // Account Name can be given for a new account, account_id is not mandatory in that case
    $lineItem = ZCRMInventoryLineItem::getInstance("{line_item_id}"); // To get ZCRMInventoryLineItem instance the id of the line item
    $lineItem->setDescription("Product_description"); // To set line item description
    $lineItem->setDiscount(20); // To set line item discount
    $lineItem->setListPrice(3412); // To set line item list price
    
    $taxInstance1 = ZCRMTax::getInstance("{tax_name}"); // to get the tax instance
    $taxInstance1->setPercentage(20); // to set the tax percentage
    $taxInstance1->setValue(50); // to set the tax value
    $lineItem->addLineTax($taxInstance1); // to add the tax to the line item
    $lineItem->setQuantity(101); // To set product quantity to this line item
    $record->addLineItem($lineItem); // to add the line item to the record of invoice
    /**
        * for price book alone
        * $record->setFieldValue("Pricing_Details", json_decode('[ { "to_range": 5, "discount": 0, "from_range": 1 }, { "to_range": 11, "discount": 1, "from_range": 6 }, { "to_range": 17, "discount": 2, "from_range": 12 }, { "to_range": 23, "discount": 3, "from_range": 18 }, { "to_range": 29, "discount": 4, "from_range": 24 } ]',true));//setting the discount , range of the pricebook record
        * $record->setFieldValue("Pricing_Model","Flat"); //setting the price book model*
        */
    $trigger=array();//triggers to include
    $lar_id="lar_id";//lead assignment rule id
    $responseIns = $record->update($trigger,$lar_id); // to update the record

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Record instances
    $records = array();
    $recordClass = 'com\zoho\crm\api\record\Record';
    //Get instance of Record Class
    $record1 = new $recordClass();
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $field = new Field("");
    // $record1->addFieldValue(Leads::City(), "City");
    // $record1->addFieldValue(Leads::LastName(), "Last Name");
    // $record1->addFieldValue(Leads::FirstName(), "First Name");
    // $record1->addFieldValue(Leads::Company(), "KKRNP");
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    // $record1->addKeyValue("Custom_field", "Value");
    // $record1->addKeyValue("Custom_field_2", "value");
    // $record1->addKeyValue("Date_1", new \DateTime('2020-03-08'));
    // $record1->addKeyValue("Date_Time_2", date_create("2021-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
    $fileDetails = array();
    // $fileDetail1 = new FileDetails();
    // $fileDetail1->setAttachmentId("34770616072005");
    // $fileDetail1->setDelete("null");
    // array_push($fileDetails, $fileDetail1);
    $fileDetail2 = new FileDetails();
    $fileDetail2->setFileId("ae9c7cefa41863e2fd0a2d8c1c");
    array_push($fileDetails, $fileDetail2);
    $fileDetail3 = new FileDetails();
    $fileDetail3->setFileId("ae9c7cefc0f7433dd2098c");
    array_push($fileDetails, $fileDetail3);
    $record1->addKeyValue("File_Upload", $fileDetails);
    //Add Record instance to the list
    array_push($records, $record1);
    //Set the list to Records in BodyWrapper instance
    $request->setData($records);
    $trigger = array("approval", "workflow", "blueprint");
    $request->setTrigger($trigger);
    //Call updateRecord method that takes BodyWrapper instance, ModuleAPIName and recordId as parameter.
    $response = $recordOperations->updateRecord( $recordId, $moduleAPIName,$request);

    sample code

Delete a Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $record->delete();

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(DeleteRecordParam::wfTrigger(), false);
    //Call deleteRecord method that takes paramInstance, ModuleAPIName and recordId as parameter.
    $response = $recordOperations->deleteRecord($recordId,$moduleAPIName, $paramInstance);

    sample code

Convert a Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("Leads", "{lead_id}"); // To get record instance
    $deal = ZCRMRecord::getInstance("deals", Null); // to get the record of deal in form of ZCRMRecord insatnce
    $deal->setFieldValue("Deal_Name", "test3"); // to set the deal name
    $deal->setFieldValue("Stage", "Qualification"); // to set the stage
    $deal->setFieldValue("Closing_Date", "2016-03-30"); // to set the closing date
    $details = array("overwrite"=>TRUE,"notify_lead_owner"=>TRUE,"notify_new_entity_owner"=>TRUE,"Accounts"=>"{account_id}","Contacts"=>"{contact_id}","assign_to"=>"{user_id}");
    $responseIn = $record->convert($deal, $details); // to convert record

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of ConvertBodyWrapper Class that will contain the request body
    $request = new ConvertBodyWrapper();
    //List of LeadConverter instances
    $data = array();
    //Get instance of LeadConverter Class
    $record1 = new LeadConverter();
    $record1->setOverwrite(true);
    $record1->setNotifyLeadOwner(true);
    $record1->setNotifyNewEntityOwner(true);
    $record1->setAccounts("34770615848125");
    $record1->setContacts("3477061358009");
    $record1->setAssignTo("3477061173021");
    $recordClass = 'com\zoho\crm\api\record\Record';
    $deals = new $recordClass();
    /*
        * Call addFieldValue method that takes two arguments
        * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
        * 2 -> Value
        */
    $field = new Field("");
    // $deals->addFieldValue(Deals::DealName(), "deal_name");
    // $deals->addFieldValue(Deals::Description(), "deals description");
    // $deals->addFieldValue(Deals::ClosingDate(), new \DateTime("2021-06-02"));
    // $deals->addFieldValue(Deals::Stage(), new Choice("Closed Won"));
    // $deals->addFieldValue(Deals::Amount(), 50.7);
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $deals->addKeyValue("Custom_field", "Value");
    $deals->addKeyValue("Custom_field_2", "value");
    $carryOverTags = new CarryOverTags();
    $carryOverTags->setAccounts(["Test"]);
    $carryOverTags->setContacts(["Test"]);
    $carryOverTags->setDeals(["Test"]);
    $record1->setCarryOverTags($carryOverTags);
    // $record1->setDeals($deals);
    //Add Record instance to the list
    array_push($data, $record1);
    //Set the list to Records in BodyWrapper instance
    $request->setData($data);
    //Call updateRecord method that takes BodyWrapper instance, ModuleAPIName and recordId as parameter.
    $response = $recordOperations->convertLead($recordId,$request );

    sample code

Upload a Photo

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $record->uploadPhoto("path/to/photo"); // $photoPath - absolute path of the photo to be uploaded.

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Get instance of FileBodyWrapper class that will contain the request file
    $fileBodyWrapper = new FileBodyWrapper();
    //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
    $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
    //Set file to the FileBodyWrapper instance
    $fileBodyWrapper->setFile($streamWrapper);
    //Call uploadPhoto method that takes FileBodyWrapper instance, moduleAPIName and recordId as parameter
    $response = $recordOperations->uploadPhoto($recordId, $moduleAPIName,$fileBodyWrapper);

    sample code

Download a Photo

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $fileResponseIns = $record->downloadPhoto(); // to download the photo

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Call downloadAttachment method that takes moduleAPIName and recordId as parameters
    $response = $recordOperations->getPhoto($recordId,$moduleAPIName );

    sample code

Delete a Photo

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $record->deletePhoto(); // $photoPath - absolute path of the photo to be uploaded.

    sample code

  • v3.x.x

    //Get instance of RecordOperations Class
    $recordOperations = new RecordOperations();
    //Call getAttachments method that takes moduleAPIName and recordId as parameter
    $response = $recordOperations->deletePhoto($recordId,$moduleAPIName);

    sample code

Tags

Get Tags

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("module_api_name"); // to get the instance of the module
    $tags = $moduleIns->getTags(); // to get the trashrecords inform of ZCRMTag array instances

    sample code

  • v3.x.x

    $tagsOperations = new TagsOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetTagsParam::module(), $moduleAPIName);
    // $paramInstance->add(GetTagsParam::myTags(), ""); //Displays the names of the tags created by the current user.
    //Call getTags method that takes paramInstance as parameter
    $response = $tagsOperations->getTags($paramInstance);

    sample code

Get Tag Count

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the instance of the module
    $tag_count = $moduleIns->getTagCount("{record_id}");

    sample code

  • v3.x.x

    $tagsOperations = new TagsOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(GetRecordCountForTagParam::module(), $moduleAPIName);
    //Call getRecordCountForTag method that takes paramInstance and tagId as parameter
    $response = $tagsOperations->getRecordCountForTag($tagId,$paramInstance);

    sample code

Create Tags

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the module instance
    $tags = array(); // to create ZCRMTag instances array
    $tag = ZCRMTag::getInstance(); // to get the tag instance
    $tag->setName("test4"); // to set the tag name
    array_push($tags, $tag); // to push the tag to array of ZCRMTag instances
    $responseIn = $moduleIns->createTags($tags); // to create the tags

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(CreateTagsParam::module(), $moduleAPIName);
    //List of Tag instances
    $tagList = array();
    $tagClass = 'com\zoho\crm\api\tags\Tag';
    //Get instance of Tag Class
    $tag1 = new $tagClass();
    $tag1->setName("tagName");
    array_push($tagList, $tag1);
    $request->setTags($tagList);
    //Call createTags method that takes BodyWrapper instance and paramInstance as parameter
    $response = $tagsOperations->createTags($request, $paramInstance);

    sample code

Update Tags

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the module instance
    $tags = array(); // to create ZCRMTag instances array
    $tag = ZCRMTag::getInstance("{tag_id}"); // to get the tag instance
    $tag->setName("testnew"); // to set the tag name
    array_push($tags, $tag); // to push the tag to array of ZCRMTag instances
    $tag = ZCRMTag::getInstance("{tag_id}"); // to get the tag instance
    $tag->setName("testnew2"); // to set the tag name
    array_push($tags, $tag); // to push the tag to array of ZCRMTag instances
    $responseIn = $moduleIns->updateTags($tags); // to update the tags

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(UpdateTagsParam::module(), $moduleAPIName);
    //List of Tag instances
    $tagList = array();
    $tagClass = 'com\zoho\crm\api\tags\Tag';
    //Get instance of Tag Class
    $tag1 = new $tagClass();
    $tag1->setId("34770616454014");
    $tag1->setName("tagName1");
    array_push($tagList, $tag1);
    $request->setTags($tagList);
    //Call updateTags method that takes BodyWrapper instance and paramInstance as parameter
    $response = $tagsOperations->updateTags($request, $paramInstance);

    sample code

Add Tags to Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("Leads"); // to get the module instance
    $recordids = array(
        "{record_id}",
    ); // array of record ids from which tags must be added
    $tagnames = array(
        "tea",
        "test2",
        "test3"
    ); // array of tags to be added
    $responseIn = $moduleIns->addTagsToRecords($recordids, $tagnames); // to add the tags to the record

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($tagNames as $tagName)
    {
        $paramInstance->add(AddTagsToMultipleRecordsParam::tagNames(), $tagName);
    }
    foreach($recordIds as $recordId)
    {
        $paramInstance->add(AddTagsToMultipleRecordsParam::ids(), $recordId);
    }
    $paramInstance->add(AddTagsToMultipleRecordsParam::overWrite(), "false");
    //Call addTagsToMultipleRecords method that takes paramInstance, moduleAPIName as parameter
    $response = $tagsOperations->addTagsToMultipleRecords($moduleAPIName,$paramInstance);

    sample code

Remove Tags from Records

  • v2.x.x

    $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("{module_api_name}"); // to get the module instance
    $recordids = array(
        "{record_id}",
        "{record_id}"
    ); // array of record ids from which tags must be removed
    $tagnames = array(
        "tea",
        "test2",
        "test3"
    ); // array of tags to be removed
    $responseIn = $moduleIns->removeTagsFromRecords($recordids, $tagnames); // to remove the tags from the records

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    $paramInstance = new ParameterMap();
    foreach($tagNames as $tagName)
    {
        $paramInstance->add(RemoveTagsFromMultipleRecordsParam::tagNames(), $tagName);
    }
    foreach($recordIds as $recordId)
    {
        $paramInstance->add(RemoveTagsFromMultipleRecordsParam::ids(), $recordId);
    }
    //Call RemoveTagsFromMultipleRecordsParam method that takes paramInstance, moduleAPIName as parameter
    $response = $tagsOperations->removeTagsFromMultipleRecords($moduleAPIName, $paramInstance);

    sample code

Add Tags to Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $tagNames = array(
        "test1",
        "test2"
    ); // to create array of tag names
    $responseIns = $record->addTags($tagNames); // to add tags

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($tagNames as $tagName)
    {
        $paramInstance->add(AddTagsToRecordParam::tagNames(), $tagName);
    }
    $paramInstance->add(AddTagsToRecordParam::overWrite(), "false");
    //Call addTagsToRecord method that takes paramInstance, moduleAPIName and recordId as parameter
    $response = $tagsOperations->addTagsToRecord($recordId, $moduleAPIName,$paramInstance);

    sample code

Remove Tags from Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $tagNames = array(
        "test1",
        "test2"
    ); // to create array of tag names
    $responseIns = $record->removeTags($tagNames); // to remove tags

    sample code

  • v3.x.x

    //Get instance of TagsOperations Class
    $tagsOperations = new TagsOperations();
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    foreach($tagNames as $tagName)
    {
        $paramInstance->add(RemoveTagsFromRecordParam::tagNames(), $tagName);
    }
    //Call removeTagsFromRecord method that takes paramInstance, moduleAPIName and recordId as parameter
    $response = $tagsOperations->removeTagsFromRecord($recordId, $moduleAPIName,$paramInstance);

    sample code

Attachments

Get Attachments

  • v2.x.x

    /* For VERSION <=2.0.6 $records = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $records->getAttachments(1, 50); // to get the attachments */
    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $param_map=array("page"=>"1","per_page"=>"200"); // key-value pair containing all the parameters - optional
    $header_map = array("if-modified-since"=>"2019-12-12T15:26:49+05:30"); // key-value pair containing all the headers - optional
    $responseIns = $record->getAttachments($param_map, $header_map); // to get the attachments

    sample code

  • v3.x.x

    //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
    $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
    //Call getAttachments method
    $response = $attachmentOperations->getAttachments();

    sample code

Upload an Attachment

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $record->uploadAttachment("/path/to/file"); // $filePath - absolute path of the attachment to be uploaded.

    sample code

  • v3.x.x

    //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
    $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
    //Get instance of FileBodyWrapper class that will contain the request file
    $fileBodyWrapper = new FileBodyWrapper();
    //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
    $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
    //Set file to the FileBodyWrapper instance
    $fileBodyWrapper->setFile($streamWrapper);
    //Call uploadAttachment method that takes FileBodyWrapper instance as parameter
    $response = $attachmentOperations->uploadAttachment($fileBodyWrapper);

    sample code

Upload Link as an Attachment

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $responseIns = $record->uploadLinkAsAttachment("{link}"); // $filePath - absolute path of the attachment to be uploaded.

    sample code

  • v3.x.x

    /Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
    $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
    //Get instance of ParameterMap Class
    $paramInstance = new ParameterMap();
    $paramInstance->add(UploadLinkAttachmentParam::attachmentUrl(), $attachmentURL);
    //Call uploadAttachment method that takes paramInstance as parameter
    $response = $attachmentOperations->uploadLinkAttachment($paramInstance);

    sample code

Download an Attachment

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $fileResponseIns = $record->downloadAttachment("{attachment_id}");

    sample code

  • v3.x.x

    //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
    $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
    //Call downloadAttachment method that takes attachmentId as parameters
    $response = $attachmentOperations->downloadAttachment($attachmentId);

    sample code

Delete an Attachment

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $fileResponseIns = $record->deleteAttachment("{attachment_id}");

    sample code

  • v3.x.x

    //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
    $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
    //Call deleteAttachment method that takes attachmentId as parameter
    $response = $attachmentOperations->deleteAttachment($attachmentId);

    sample code

RelatedRecords

Update a Related Record

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $junctionrecord = ZCRMJunctionRecord::getInstance("{module_api_name}", "{record_id}"); // to get the junction record instance
    $responseIns = $record->addRelation($junctionrecord); // to add a relation between the record and the junction record

    sample code

  • v3.x.x

    //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
    $relatedRecordsOperations = new RelatedRecordsOperations( $relatedListAPIName,  $recordId,  $moduleAPIName);
    //Get instance of BodyWrapper Class that will contain the request body
    $request = new BodyWrapper();
    //List of Record instances
    $records = array();
    //Get instance of Record Class
    $record1 = new Record();
    /*
        * Call addKeyValue method that takes two arguments
        * 1 -> A string that is the Field's API Name
        * 2 -> Value
        */
    $record1->addKeyValue("list_price", 50.56);
    //Add Record instance to the list
    array_push($records, $record1);
    //Set the list to Records in BodyWrapper instance
    $request->setData($records);
    //Call updateRecord method that takes BodyWrapper instance, relatedRecordId as parameter.
    $response = $relatedRecordsOperations->updateRelatedRecord($relatedListId,$request);

    sample code

Remove Relation between Records

  • v2.x.x

    $record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
    $junctionrecord = ZCRMJunctionRecord::getInstance("{module_api_name}", "{record_id}"); // to get the junction record instance
    $responseIns = $record->removeRelation($junctionrecord); // to add a relation between the record and the junction record

    sample code

  • v3.x.x

    //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
    $relatedRecordsOperations = new RelatedRecordsOperations($relatedListAPIName,$recordId,$moduleAPIName);
    //Call updateRecord method that takes relatedListId as parameter.
    $response = $relatedRecordsOperations->delinkRecord($relatedListId);

    sample code