Java SDK Samples

Java SDK Samples

Module APIs

Get List Of Modules - List<ZCRMModule>

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. BulkAPIResponse response = client.getAllModules();
  3. List<ZCRMModule> modules = (List<ZCRMModule>) response.getData();


Meta data APIs

Module Meta Data - ZCRMModule

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. APIResponse response = client.getModule("Products");//module api name
  3. ZCRMModule module = (ZCRMModule) response.getData();

Field Meta Data - List<ZCRMField>

  1. ZCRMModule module = ZCRMModule.getInstance("Products"); // module apiname
  2. BulkAPIResponse response = module.getAllFields();
  3. List<ZCRMField> fields = (List<ZCRMField>)response.getData();

Layout with ID - ZCRMLayout

  1. ZCRMModule module = ZCRMModule.getInstance("Products");// module apiname
  2. APIResponse response = module.getLayoutDetails(12345690l);//layoutID
  3. ZCRMLayout layout = (ZCRMLayout) response.getData();

Layouts - List<ZCRMLayout>

  1. ZCRMModule module = ZCRMModule.getInstance("Products"); // module apiname
  2. BulkAPIResponse response = module.getLayouts();
  3. List<ZCRMLayout> layouts = (List<ZCRMLayout>) response.getData();
  1. APIResponse response = MetaDataAPIHandler.getInstance().getModule("Products");//module api name
  2. ZCRMModule module = (ZCRMModule) response.getData();
  3. List<ZCRMModuleRelation> relationList = module.getRelatedLists();

Custom Views - List<ZCRMCustomView>

  1. ZCRMModule module = ZCRMModule.getInstance("Contacts");// module api name
  2. BulkAPIResponse response = module.getCustomViews();
  3. List<ZCRMCustomView> customViews = (List<ZCRMCustomView>) response.getData();

Single Custom View - ZCRMCustomView

  1. ZCRMModule module = ZCRMModule.getInstance("Contacts");
  2. APIResponse response = module.getCustomView(98658369836l);
  3. ZCRMCustomView customView = (ZCRMCustomView) response.getData();


Users APIs

Get Users - List<ZCRMUser>

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. BulkAPIResponse response =
  3. client.getOrganisationInstance().getAllUsers();
  4. List<ZCRMUser> users = (List<ZCRMUser>) response.getData());

Get Single User with Data - ZCRMUser

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. APIResponse response = client.getOrganisationInstance().getUser(123456789l);//userID
  3. ZCRMUser user = (ZCRMUser) response.getData();

Get All Admin Users - List<ZCRMUser>

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. BulkAPIResponse response = client.getOrganisationInstance().getAllAdminUsers();
  3. List<ZCRMUser> users = (List<ZCRMUser>) response.getData();

Get All Active Users - List<ZCRMUser>

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. BulkAPIResponse response = client.getOrganisationInstance().getAllActiveUsers();
  3. List<ZCRMUser> users = (List<ZCRMUser>) response.getData();

Get All InActive Users - List<ZCRMUser>

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. BulkAPIResponse response = client.getOrganisationInstance().getAllInActiveUsers();
  3. List<ZCRMUser> users = (List<ZCRMUser>)response.getData();


Organization APIs

Organization Data - ZCRMOrganization

  1. ZCRMRestClient client = ZCRMRestClient.getInstance();
  2. APIResponse response = client.getOrganization();
  3. ZCRMOrganization org = (ZCRMOrganization) response.getData();


Record APIs

List of records - List<ZCRMRecord>

  1. ZCRMModule module = ZCRMModule.getInstance("Products");
  2. BulkAPIResponse response = module.getRecords(425476547854l, "Company",
  3. CommonUtil.SortOrder.asc, 1, 4); // get Records with cvID, sortField, sortOrder, startIndex and endIndex.
  4. List<ZCRMRecord> records = (List<ZCRMRecord>)response.getData();

Insert Records - List<ZCRMRecord>

  1. List<ZCRMRecord> records = new ArrayList<>();
  2. ZCRMRecord record1 = new ZCRMRecord("Products"); //module api name
  3. ZCRMUser owner = ZCRMUser.getInstance(12345678l); // user id
  4. record1.setOwner(owner);
  5. record1.setFieldValue("Product_Name", "mass_create1"); // field api name with its value
  6. ZCRMRecord record2 = new ZCRMRecord("Products"); //module api name
  7. ZCRMUser owner = ZCRMUser.getInstance(5676875678l); // user id
  8. record2.setOwner(owner);
  9. record2.setFieldValue("Product_Name", "mass_create2"); // field api name with its value
  10. records.add(record1);
  11. records.add(record2)
  12. ZCRMModule module = ZCRMModule.getInstance("Products"); //module api name
  13. BulkAPIResponse response = module.createRecords(records);
  14. List<ZCRMRecord> insertedRecords = (List<ZCRMRecord>) response.getData();
  15. List<BulkAPIResponse.EntityResponse> entityResponses = response.getEntityResponses(); // to check the status of the request
  16. String rec1Status = entityResponses.get(0).getStatus(); //check status of record 1
  17. String rec2Status = entityResponses.get(1).getStatus(); //check status of record 2

Update Records - List<ZCRMRecord>

  1. List<Long> entityIDs = new ArrayList<>(); // list of record ids
  2. entityIDs.add(426000621092l);
  3. entityIDs.add(426859000010l);
  4. ZCRMModule module = ZCRMModule.getInstance("Products"); //module api name
  5. BulkAPIResponse response = (ZCRMRecord) module.updateRecords(entityIDs,"Product_Name","massUpdate").getData(); // field api name with its value to update
  6. List<ZCRMRecord> updatedRecords = (List<ZCRMRecord>) response.getData();
  7. List<BulkAPIResponse.EntityResponse> entityResponses = response.getEntityResponses(); // to check the status of the request
  8. String rec1Status = entityResponses.get(0).getStatus(); //check status of record 1
  9. String rec2Status = entityResponses.get(1).getStatus(); //check status of record 2

Insert or Update (Upsert) - List<ZCRMRecord>

  1. List records = new ArrayList<>();
  2. ZCRMRecord record1 = new ZCRMRecord("Leads"); // module api name
  3. record.setFieldValue("Company", “Zylker”);
  4. record.setFieldValue("First_name", “Daly”);
  5. record.setFieldValue("Last_Name", “Paul”);
  6. record.setFieldValue("Email", “p.daly@zylker.com”);
  7. record.setFieldValue("State", “Texas”);
  8. ZCRMRecord record2 = new ZCRMRecord("Leads"); // module api name
  9. record.setFieldValue("Company", “ekhrj”);
  10. record.setFieldValue("First_name", “John”);
  11. record.setFieldValue("Last_Name", “smith”);
  12. record.setFieldValue("Email", “john.a@ekhrj.com”);
  13. record.setFieldValue("State", “Texas”);
  14. records.add(record1);
  15. records.add(record2);
  16. ZCRMModule module = ZCRMModule.getInstance("Leads"); //module api name
  17. BulkAPIResponse response = module.upsert(records);
  18. List<ZCRMRecord> upsertedRecords = (List<ZCRMRecord>) response.getData();
  19. List<BulkAPIResponse.EntityResponse> entityResponses = response.getEntityResponses();// to check the status of the request
  20. String rec1Status = entityResponses.get(0).getStatus();//check status of record 1
  21. String rec2Status = entityResponses.get(1).getStatus();//check status of record 2

Get List of Deleted Records - List<ZCRMRecord>

  1. ZCRMModule module = ZCRMModule.getInstance("Leads"); //module api name
  2. BulkAPIResponse response = module.getAllDeletedRecords();
  3. List<ZCRMRecord> deletedRecords = (List<ZCRMRecord>) response.getData();
  4. BulkAPIResponse response = module.getRecycleBinRecords();
  5. BulkAPIResponse response = module.getPermanentlyDeletedRecords();

Search Records - List<ZCRMRecord>

  1. ZCRMModule module = ZCRMModule.getInstance("Products"); // module api name
  2. BulkAPIResponse response = module.searchRecords("xyz", 1, 4);// get search records with page and per page count
  3. List<ZCRMRecord> records = (List<ZCRMRecord>) response.getData(); // search string


Single Record APIs

Get a Specific Record - ZCRMRecord

  1. ZCRMModule module = ZCRMModule.getInstance("Products");//module api name
  2. APIResponse response = module.getRecord(1234567890l);//record id
  3. ZCRMRecord record = (ZCRMRecord) response.getData();

Update a Specific Record - ZCRMRecord

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",1234567l);// module api name with its record id
  2. record.setFieldValue("Product_Name","name");// field api name with the value to be updated
  3. ZCRMRecord lookup = ZCRMRecord.getInstance("Vendors",123456789l); // vendor module api name with its record id
  4. record.setFieldValue("Vendor_Name", lookup);
  5. APIResponse response = record.update();
  6. ZCRMRecord updatedRecord = (ZCRMRecord) response.getData();
  7. String recStatus = response.getStatus(); // check status of the record

Insert a new Record - ZCRMRecord

  1. ZCRMRecord record = new ZCRMRecord("Products"); // module api name
  2. ZCRMUser owner = ZCRMUser.getInstance(123456789l);// userId with userName
  3. record.setOwner(owner);
  4. record.setFieldValue("Product_Name", “Cello”);
  5. record.setFieldValue("Product_Code", “c21”);
  6. ZCRMRecord product = ZCRMRecord.getInstance("Products",389468745784l);
  7. ZCRMInventoryLineItem zcrmInventoryLineItem = new
  8. ZCRMInventoryLineItem(product);
  9. zcrmInventoryLineItem.setQuantity(15.00);
  10. zcrmInventoryLineItem.setDescription("description");
  11. zcrmInventoryLineItem.setDiscount(12.00);
  12. zcrmInventoryLineItem.setDiscountPercentage(20.0);
  13. zcrmInventoryLineItem.setListPrice(280.0);
  14. ZCRMTax tax = ZCRMTax.getInstance("SalesTax");
  15. tax1.setPercentage(5);
  16. zcrmInventoryLineItem.addLineTax(tax);
  17. record.addLineItem(zcrmInventoryLineItem);
  18. APIResponse response = record.create();
  19. ZCRMRecord createdRecord = (ZCRMRecord) response.getData();
  20. String recStatus = response.getStatus();

Delete a Specific Record - ZCRMRecord

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",12347986875l);//module api name with record id
  2. APIResponse response = record.delete();
  3. String recStatus = response.getStatus();

Convert Lead - HashMap with ID's of Accounts, Deals and Contacts

  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",3247354544l);//module api name with record id
  2. HashMap<String,Long> map = record.convert(); //return
  3. ("Accounts":"42685937005","Deals":null,"Contacts":"42685937007")
  4. Long accountsId = map.get("Accounts");
  5. Long dealsId = map.get("Deals");
  6. Long contactsId = map.get("Contacts");

Convert with potential

  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",3247354544l);//module api name with record id
  2. ZCRMRecord potential = new ZCRMRecord("Potentials");
  3. potential.setFieldValue("Potential_Name","xys");
  4. potential.setFieldValue("Account_Name","xyz");
  5. potential.setFieldValue("Closing_Date","2017-11-09T14:44:04+05:30");
  6. potential.setFieldValue("Stage","Qualification");
  7. potential.setFieldValue("Contact_Role","Purchasing");
  8. HashMap<String,Long> map = record.convert(potential);// return
  9. ("Accounts":"426858077","Deals":"426850938081","Contacts":"426859079")
  10. Long accountsId = map.get("Accounts");
  11. Long dealsId = map.get("Deals");
  12. Long contactsId = map.get("Contacts");

Convert with potential and user

  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",3247354544l);//module api name with record id
  2. ZCRMRecord potential = new ZCRMRecord("Potentials");
  3. potential.setFieldValue("Potential_Name","xys");
  4. potential.setFieldValue("Account_Name","xyz");
  5. potential.setFieldValue("Closing_Date","2017-11-09T14:44:04+05:30");
  6. potential.setFieldValue("Stage","Qualification");
  7. potential.setFieldValue("Contact_Role","Purchasing");
  8. ZCRMUser user = ZCRMUser.getInstance(426859003l); // user id
  9. HashMap<String,Long> map = record.convert(potential,user); // return
  10. ("Accounts":"4268590077","Deals":"42000938081","Contacts":"426858079")
  11. Long accountsId = map.get("Accounts");
  12. Long dealsId = map.get("Deals");
  13. Long contactsId = map.get("Contacts");


  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",410888000000698006);//module api name with record id
  2. BulkAPIResponse response = record.getRelatedListRecords("Notes");
  3. List<ZCRMNote> notes = (List<ZCRMNote>) response.getData();//relatedList name
  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",41080698006);//module api name with record id
  2. APIResponse response = record.addRelation("Related_list_apiname",related_record_id);
  3. String recStatus = response.getStatus(); //check status of the update relation
  1. ZCRMRecord record = ZCRMRecord.getInstance("Leads",41080698006);//module api name with record id
  2. APIResponse response = record.deleteRelation("Related_list_apiname",related_record_id);
  3. String recStatus = response.getStatus(); //check status of the delete relation


Notes APIs

Create Specific Notes - ZCRMNote

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. ZCRMNote note = new ZCRMNote(record);
  3. note.setContent("test msg");
  4. note.setTitle("test class notes");
  5. APIResponse response = record.addNote(note);
  6. ZCRMNote createdNote = (ZCRMNote) response.getData();
  7. String recStatus =response.getStatus();

Get Specific Notes Data - List<ZCRMNote>

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. BulkAPIResponse response = record.getNotes();
  3. List<ZCRMNote> notes = (List<ZCRMNote>) response.getData()

Update Notes - ZCRMNote

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. ZCRMNote note = ZCRMNote.getInstance(record,374968745l);// notesID
  3. note.setContent("update message");
  4. APIResponse response = record.updateNote(note);
  5. ZCRMNote updatedNote = (ZCRMNote) response.getData();
  6. String recStatus =response.getStatus();

Delete Notes - ZCRMNote

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. ZCRMNote note = ZCRMNote.getInstance(record,4658757465l);//NotesID
  3. APIResponse response = record.deleteNote(note);
  4. ZCRMNote deletedNote = (ZCRMNote) response.getData();
  5. String recStatus =response.getStatus();


Files and Attachments APIs

Get List of Attachments - List<ZCRMAttachment>

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. BulkAPIResponse response = record.getAllAttachmentsDetails();
  3. List<ZCRMAttachment> list = ((List<ZCRMAttachment>) response.getData());

Upload an Attachment - ZCRMAttachment

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. APIResponse response = record.uploadAttachment("FilePath");
  3. ZCRMAttachment uploadAttachment = (ZCRMAttachment) response.getData();
  4. String requestStatus =response.getStatus();

Download an attachment - FileAsStream

  1. ZCRMRecord record = ZCRMRecord.getInstance("Products",23857634545l);//module api name with record id
  2. FileAPIResponse response = this.record.downloadAttachment(476487548348l);//attachmentID
  3. InputStream inputStream = response.getFileAsStream();
  4. CommonUtil.saveStreamAsFile(inputStream,
  5. "PathToSaveDownloadedFile",response.getFileName());

Upload a Photo - NULL

  1. ZCRMRecord record = ZCRMRecord.getInstance("Contacts", 975824386248l);//module apiname with record id
  2. APIResponse response = record.uploadPhoto("ImagePath");
  3. String requestStatus =response.getStatus();

Download a Photo - FileAsStream

  1. ZCRMRecord record = ZCRMRecord.getInstance("Contacts",426857003l);//module api name with record id
  2. FileAPIResponse response = record.downloadPhoto();
  3. InputStream inputStream = response.getFileAsStream();
  4. CommonUtil.saveStreamAsFile(inputStream, "PathToSaveDownloadedPhoto", "image_name.png");



    • Related Articles

    • PHP SDK Sample

      Here is the sample PHP code block for the getFieldDetails method. <?php require 'vendor/autoload.php'; class Module{     public function __construct()     {         ZCRMRestClient::initialize();     }     public function getFieldDetails() {         ...
    • Java SDK - Overview

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

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

      Let us quickly walk through the sequence of steps to use Java SDK.       1. Register a Zoho client as described in the page link.       2. Create the File hierarchy in your eclipse project as shown below:                  3. Create a folder ...
    • Configuration - Java SDK

      Setting up the configuration is a system engineering process, for establishing and maintaining the consistency of the application's performance, functional and physical attributes with its requirements, design and operational information throughout ...