Java SDK Samples - Module Operations

Meta Data
Get List of Module Fields

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getAllFields() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		BulkAPIResponse response= moduleIns.getAllFields();;//to get the field
        List<ZCRMField> fields= (List<ZCRMField> )response.getData();//to get the array of ZCRMField instances
        for( ZCRMField field :  fields){//each field
            System.out.println(field.getApiName());
            System.out.println(field.getCreatedSource());
            System.out.println(field.getDataType());
            System.out.println(field.getDefaultValue());
            System.out.println(field.getDisplayName());
            System.out.println(field.getFormulaReturnType());
            System.out.println(field.getToolTip());
            System.out.println(field.getId());
            HashMap<String, Object> lookupdetails =(field.getLookupDetails());
            for (HashMap.Entry<String, Object> entry : lookupdetails.entrySet()) {
                System.out.println(entry.getKey() + " : " + entry.getValue());
            }
            System.out.println(field.getMaxLength());
            System.out.println(field.getWebhook());
            System.out.println(field.getType());
            System.out.println(field.getSubformTabId());
            HashMap<String, Object> SubformDetails =(field.getSubformDetails());
            for (HashMap.Entry<String, Object> entry : SubformDetails.entrySet()) {
                System.out.println(entry.getKey() + " : " + entry.getValue());
            }
            System.out.println(field.getSequenceNo());
            System.out.println(field.getRoundingOption());
            System.out.println(field.getPrecision());
            System.out.println(field.isCustomField());
            System.out.println(field.isExportable());
            System.out.println(field.isMandatory());
            System.out.println(field.isPresentInCreateLayout());
            System.out.println(field.isPresentInQuickCreateLayout());
            System.out.println(field.isPresentInViewLayout());
            System.out.println(field.isReadOnly());
            System.out.println(field.isRestricted());
            System.out.println(field.isVisible());
            List<ZCRMPickListValue> picklists=(field.getPickListValues());
            for(ZCRMPickListValue picklist : picklists){
            	System.out.println(picklist.getActualName());
            	System.out.println(picklist.getDisplayName());
            	System.out.println(picklist.getSequenceNumber());
            	System.out.println(picklist.getMaps().toString());
            }
            HashMap<String, Object> MultiselectLookup =(field.getMultiselectLookup());
            for (HashMap.Entry<String, Object> entry : MultiselectLookup.entrySet()) {
                System.out.println(entry.getKey() + " : " + entry.getValue());
            }
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getAllFields();
		
	}
}
 

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getRelatedLists() throws Exception{
		 ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
         BulkAPIResponse response= moduleIns.getRelatedLists();//to get all the related lists
         List<ZCRMModuleRelation> relatedlists=( List<ZCRMModuleRelation>)response.getData();//to get the related lists as the instance of ZCRMModuleRelatedList
        for(ZCRMModuleRelation relatedlist:relatedlists)//for eachrelated list
        {
            System.out.println(relatedlist.getApiName());//to get the api name of the module related list
            System.out.println(relatedlist.getModule());//to get the module api name to which this module related list is belongs
            System.out.println(relatedlist.getLabel());//to get the display Label of the module related list 
            System.out.println(relatedlist.isVisible());//to check whether the module related list is visible
            System.out.println(relatedlist.getName());//to get name of the module related list
            System.out.println(relatedlist.getId());//to get id of the module related list
            System.out.println(relatedlist.getType());//to get the type of the module related list
            System.out.println(relatedlist.getParentModuleAPIName());
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getRelatedLists();
		
	}
}
 
Get List of Layouts of a Module

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getLayouts() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		BulkAPIResponse response= moduleIns.getLayouts();
        List<ZCRMLayout> layouts= (List<ZCRMLayout> )response.getData();//to get the array of ZCRMField instances
        for(ZCRMLayout layout : layouts){
        	System.out.println(layout.getCreatedTime());
        	System.out.println(layout.getModifiedTime());
        	System.out.println(layout.getName());
        	System.out.println(layout.getStatus());
        	List<ZCRMProfile> profiles=(layout.getAccessibleProfiles());
        	for(ZCRMProfile profile : profiles){
            	System.out.println(profile.getId());
            	System.out.println(profile.getName());
            }
        	ZCRMUser user=(layout.getCreatedBy());
        	if(user!=null){
        		user.getId();
        		user.getFullName();
        	}
        	System.out.println(layout.getId());
        	ZCRMUser user2=(layout.getModifiedBy());
        	if(user2!=null){
        		user2.getId();
        		user2.getFullName();
        	}
        	List<ZCRMSection> sections=layout.getSections();
        	for(ZCRMSection section : sections){
            	System.out.println(section.getColumnCount());
            	System.out.println(section.getDisplayName());
            	System.out.println(section.getName());
            	System.out.println(section.getSequence());
            	System.out.println(section.isSubformSection());
            	List <ZCRMField>fields=(section.getAllFields());
            	for( ZCRMField field :  fields){//each field
                    System.out.println(field.getApiName());
                    System.out.println(field.getCreatedSource());
                    System.out.println(field.getDataType());
                    System.out.println(field.getDefaultValue());
                    System.out.println(field.getDisplayName());
                    System.out.println(field.getFormulaReturnType());
                    System.out.println(field.getToolTip());
                    System.out.println(field.getId());
                    HashMap<String, Object> lookupdetails =(field.getLookupDetails());
                    for (HashMap.Entry<String, Object> entry : lookupdetails.entrySet()) {
                        System.out.println(entry.getKey() + " : " + entry.getValue());
                    }
                    System.out.println(field.getMaxLength());
                    System.out.println(field.getWebhook());
                    System.out.println(field.getType());
                    System.out.println(field.getSubformTabId());
                    HashMap<String, Object> SubformDetails =(field.getSubformDetails());
                    for (HashMap.Entry<String, Object> entry : SubformDetails.entrySet()) {
                        System.out.println(entry.getKey() + " : " + entry.getValue());
                    }
                    System.out.println(field.getSequenceNo());
                    System.out.println(field.getRoundingOption());
                    System.out.println(field.getPrecision());
                    System.out.println(field.isCustomField());
                    System.out.println(field.isExportable());
                    System.out.println(field.isMandatory());
                    System.out.println(field.isPresentInCreateLayout());
                    System.out.println(field.isPresentInQuickCreateLayout());
                    System.out.println(field.isPresentInViewLayout());
                    System.out.println(field.isReadOnly());
                    System.out.println(field.isRestricted());
                    System.out.println(field.isVisible());
                    List<ZCRMPickListValue> picklists=(field.getPickListValues());
                    for(ZCRMPickListValue picklist : picklists){
                    	System.out.println(picklist.getActualName());
                    	System.out.println(picklist.getDisplayName());
                    	System.out.println(picklist.getSequenceNumber());
                    	System.out.println(picklist.getMaps().toString());
                    }
                    HashMap<String, Object> MultiselectLookup =(field.getMultiselectLookup());
                    for (HashMap.Entry<String, Object> entry : MultiselectLookup.entrySet()) {
                        System.out.println(entry.getKey() + " : " + entry.getValue());
                    }
                }
            }
        	System.out.println(layout.isVisible());   	
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getLayouts();
		
	}
}
 
Get List of Custom Views of a Module

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getCustomViews() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,Leads" is the module api name
		BulkAPIResponse response= moduleIns.getCustomViews();
        List<ZCRMCustomView> customviews= (List<ZCRMCustomView> )response.getData();//to get the array of ZCRMField instances
        for(ZCRMCustomView customview :customviews){
        	System.out.println(customview.getCategory());
        	System.out.println(customview.getDisplayName());
        	System.out.println(customview.getModuleAPIName());
        	System.out.println(customview.getName());
        	System.out.println(customview.getSortBy());
        	System.out.println(customview.getSystemName());
        	System.out.println(customview.getFavorite());
        	List <String> fields=customview.getFields();
        	for(String field:fields){
        		System.out.println(field);
        	}
        	System.out.println(customview.getId());
        	System.out.println(customview.getSortOrder());
        	System.out.println(customview.isDefault());
        	
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getCustomViews();
		
	}
}
 
Get a Layout of a Module

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getLayoutDetails() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,Leads" is the module api name
		APIResponse response= moduleIns.getLayoutDetails(35240330091055L);//35240330091055L-layout id
        ZCRMLayout layout= (ZCRMLayout)response.getData();//to get the array of ZCRMField instances
        System.out.println(layout.getCreatedTime());
    	System.out.println(layout.getModifiedTime());
    	System.out.println(layout.getName());
    	System.out.println(layout.getStatus());
    	List<ZCRMProfile> profiles=(layout.getAccessibleProfiles());
    	for(ZCRMProfile profile : profiles){
        	System.out.println(profile.getId());
        	System.out.println(profile.getName());
        }
    	ZCRMUser user=(layout.getCreatedBy());
    	if(user!=null){
    		user.getId();
    		user.getFullName();
    	}
    	System.out.println(layout.getId());
    	ZCRMUser user2=(layout.getModifiedBy());
    	if(user2!=null){
    		user2.getId();
    		user2.getFullName();
    	}
    	List<ZCRMSection> sections=layout.getSections();
    	for(ZCRMSection section : sections){
        	System.out.println(section.getColumnCount());
        	System.out.println(section.getDisplayName());
        	System.out.println(section.getName());
        	System.out.println(section.getSequence());
        	System.out.println(section.isSubformSection());
        	List <ZCRMField>fields=(section.getAllFields());
        	for( ZCRMField field :  fields){//each field
                System.out.println(field.getApiName());
                System.out.println(field.getCreatedSource());
                System.out.println(field.getDataType());
                System.out.println(field.getDefaultValue());
                System.out.println(field.getDisplayName());
                System.out.println(field.getFormulaReturnType());
                System.out.println(field.getToolTip());
                System.out.println(field.getId());
                HashMap<String, Object> lookupdetails =(field.getLookupDetails());
                for (HashMap.Entry<String, Object> entry : lookupdetails.entrySet()) {
                    System.out.println(entry.getKey() + " : " + entry.getValue());
                }
                System.out.println(field.getMaxLength());
                System.out.println(field.getWebhook());
                System.out.println(field.getType());
                System.out.println(field.getSubformTabId());
                HashMap<String, Object> SubformDetails =(field.getSubformDetails());
                for (HashMap.Entry<String, Object> entry : SubformDetails.entrySet()) {
                    System.out.println(entry.getKey() + " : " + entry.getValue());
                }
                System.out.println(field.getSequenceNo());
                System.out.println(field.getRoundingOption());
                System.out.println(field.getPrecision());
                System.out.println(field.isCustomField());
                System.out.println(field.isExportable());
                System.out.println(field.isMandatory());
                System.out.println(field.isPresentInCreateLayout());
                System.out.println(field.isPresentInQuickCreateLayout());
                System.out.println(field.isPresentInViewLayout());
                System.out.println(field.isReadOnly());
                System.out.println(field.isRestricted());
                System.out.println(field.isVisible());
                List<ZCRMPickListValue> picklists=(field.getPickListValues());
                for(ZCRMPickListValue picklist : picklists){
                	System.out.println(picklist.getActualName());
                	System.out.println(picklist.getDisplayName());
                	System.out.println(picklist.getSequenceNumber());
                	System.out.println(picklist.getMaps().toString());
                }
                HashMap<String, Object> MultiselectLookup =(field.getMultiselectLookup());
                for (HashMap.Entry<String, Object> entry : MultiselectLookup.entrySet()) {
                    System.out.println(entry.getKey() + " : " + entry.getValue());
                }
        	}
    	}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getLayoutDetails();		
	}
}
 
Get a Custom View of a Module

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getCustomView() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,is the module name,"Leads" is the module api name
		APIResponse response= moduleIns.getCustomView(35240330087501L);//modified since is optional,35240330087501L-custom view id
        ZCRMCustomView customview= (ZCRMCustomView )response.getData();//to get the array of ZCRMField instances
    	System.out.println(customview.getCategory());
    	System.out.println(customview.getDisplayName());
    	System.out.println(customview.getModuleAPIName());
    	System.out.println(customview.getName());
    	System.out.println(customview.getSortBy());
    	System.out.println(customview.getSystemName());
    	System.out.println(customview.getFavorite());
    	List <String> fields=customview.getFields();
    	for(String field:fields){
    		System.out.println(field);
    	}
    	System.out.println(customview.getId());
    	System.out.println(customview.getSortOrder());
    	System.out.println(customview.isDefault());
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getCustomView();
		
	}
}
 
Records
Get List of Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getAllRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		long cvid=35240330087501L;//customview id
		String sortbyfield="Lead_owner";//sortby field api name
		SortOrder sortorder=CommonUtil.SortOrder.asc;//sort order
		int page=1;//page
		int perpage=200;//records per page
		String modifiedsince="2019-01-04T16:31:50+05:30";//to get records modified since this datetime in iso 8601 format
		boolean isconverted=true;//to get the record which is converted or unconverted(set null if both) 
		boolean isapproved=true;//to get the record which is approved or unapproved(set null if both)
		List<String> fields=new ArrayList<>();//to get the specific fields
		fields.add("{field_api_name");
		boolean includeprivatefields=true;//to get the private fields
		BulkAPIResponse response=moduleIns.getRecords(cvid,sortbyfield,sortorder,page,perpage,modifiedsince,isconverted,isapproved,fields,includeprivatefields);//to get the record ,if any parameter is not needed set null
		List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
		for(ZCRMRecord record : records){
			System.out.println(record.getCreatedTime());
			System.out.println(record.getFieldValue("Company"));
			System.out.println(record.getLookupLabel());
			System.out.println(record.getModifiedTime());
			System.out.println(record.getModuleAPIName());
			List<ZCRMPriceBookPricing> pricings=(record.getPriceDetails());
			for(ZCRMPriceBookPricing pricing:pricings){
				   System.out.println(pricing.getId()); //To get the record's price_id
	               System.out.println(pricing.getToRange()); //To get the price_detail record's to_range
	               System.out.println(pricing.getFromRange()); //To get price_detail record's from_range
	               System.out.println(pricing.getDiscount());
			}
			ZCRMUser owner=(record.getOwner());
			if(owner!=null){
				System.out.println(owner.getId());
				System.out.println(owner.getFirstName());
			}
			ZCRMUser user1=(record.getModifiedBy());
			if(user1!=null){
				System.out.println(user1.getId());
				System.out.println(user1.getFirstName());
			}
			ZCRMUser user2=(record.getCreatedBy());
			if(user2!=null){
				System.out.println(user2.getId());
				System.out.println(user2.getFirstName());
			}
			System.out.println(record.getEntityId());
			ZCRMLayout layout=(record.getLayout());
			System.out.println(layout.getId());
			System.out.println(layout.getName());
			List<ZCRMInventoryLineItem> lineitems=(record.getLineItems());
			for(ZCRMInventoryLineItem lineItem :lineitems){
				 System.out.println(lineItem.getId()); //To get line_item id
	             System.out.println(lineItem.getListPrice()); //To get line_item list price
	             System.out.println(lineItem.getQuantity()); //To get line_item quantity
	             System.out.println(lineItem.getDescription()); //To get line_item description
	             System.out.println(lineItem.getTotal()); //To get line_item total amount
	             System.out.println(lineItem.getDiscount()); //To get line_item discount
	             System.out.println(lineItem.getDiscountPercentage()); //To get line_item discount percentage
	             System.out.println(lineItem.getTotalAfterDiscount()); //To get line_item amount after discount
	             System.out.println(lineItem.getTaxAmount()); //To get line_item tax amount
	             System.out.println(lineItem.getNetTotal()); //To get line_item net total amount
	             System.out.println(lineItem.getUnitPrice()); //To get line_item delete flag
	             System.out.println(lineItem.getProduct().getEntityId()); //To get line_item product's entity id
	             System.out.println(lineItem.getProduct().getLookupLabel()); //To get line_item product's lookup label
	             List <ZCRMTax> lineTaxs=lineItem.getLineTax(); //To get line_item's line_tax as array
	             for (ZCRMTax lineTax :lineTaxs )
	             {
	                 System.out.println(lineTax.getTaxName()); //To get line_tax name
	                 System.out.println(lineTax.getPercentage()); //To get line_tax percentage
	                 System.out.println(lineTax.getValue()); //To get line_tax value
	             }
			}
			HashMap<String, Object> data=(record.getData());
			for (Map.Entry<String, Object> entry : data.entrySet())  
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue()); 
			List <ZCRMTag> tags=record.getTagList();
			for (ZCRMTag tag :tags )
	        {
	            System.out.println(tag.getName()); //To get line_tax name
	            System.out.println(tag.getId()); //To get line_tax percentage
	        }
			List <ZCRMTax> taxes=record.getTaxList(); //To get line_item's line_tax as array
	        for (ZCRMTax tax :taxes )
	        {
	            System.out.println(tax.getTaxName()); //To get line_tax name
	            System.out.println(tax.getPercentage()); //To get line_tax percentage
	            System.out.println(tax.getValue()); //To get line_tax value
	        }
	        List <ZCRMEventParticipant> participants=record.getParticipants(); //To get line_item's line_tax as array
	        for (ZCRMEventParticipant participant :participants )
	        {
	        	 System.out.println(participant.getName()); //To get the record's participant name
	             System.out.println(participant.getEmail()); //To get the record's participant email
	             System.out.println(participant.getId()); //To get the record's participant id
	             System.out.println(participant.getType()); //To get the record's participant type
	             System.out.println(participant.isInvited()); //To check if the record's participant(s)) are invited or not
	             System.out.println(participant.getStatus()); //To get the record's participants' status
	        }
			System.out.println(record.getParticipants());
			HashMap<String, Object> properties=(record.getAllProperties());
			for (Map.Entry<String, Object> entry : properties.entrySet())  {
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue().toString()); 
	            
			}
			System.out.println(record.getProperty("$approved".toString()));
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getAllRecords();
		
	}
}
 
Insert Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void createRecords() throws Exception {
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Invoices");//To get module instance,"Invoices" is the module api name
		ZCRMRecord record=ZCRMRecord.getInstance("Invoices",null); //To get ZCRMRecord instance,"Invoices" is the module api name
         record.setFieldValue("Subject","Invoice"); //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
         record.setFieldValue("Account_Name",35240330246560L);//35240330246560L- account id
        
        /** Following methods are being used only by Inventory modules **/

         ZCRMInventoryLineItem lineItem=ZCRMInventoryLineItem.getInstance(null); //To get ZCRMInventoryLineItem instance
         lineItem.setDescription("Product_description"); //To set line item description
         lineItem.setDiscount(233.23); //To set line item discount
         lineItem.setListPrice(100.00); //To set line item list price
        
         ZCRMTax taxInstance1=ZCRMTax.getInstance("Sales Tax"); //To get ZCRMTax instance,"Sales Tax" is the tax name
         taxInstance1.setPercentage(2); //To set tax percentage
         taxInstance1.setValue(50); //To set tax value
         lineItem.addLineTax( taxInstance1); //To set line tax to line item
        
         ZCRMTax taxInstance2=ZCRMTax.getInstance("tax"); //To get ZCRMTax instance,"Tax" is the tax name
         taxInstance2.setPercentage(2); //To set tax percentage
         taxInstance2.setValue(50); //To set tax value
         lineItem.addLineTax( taxInstance2); //To set line tax to line item
         ZCRMRecord product =ZCRMRecord.getInstance("Products",35240330307001L);//35240330307001L -entity id, products is the module n me
         lineItem.setProduct(product); //To set product to line item
         lineItem.setQuantity(100.00); //To set product quantity to this line item
         record.addLineItem( lineItem);  //to add the line item to the record
         List<ZCRMRecord> records= Arrays.asList(record);
         List<CommonUtil.Trigger> triggers= Arrays.asList(CommonUtil.Trigger.workflow,CommonUtil.Trigger.approval,CommonUtil.Trigger.blueprint); //pushing the record to the array
         Long lar_id={lead_assignment_id}; 
         BulkAPIResponse responses= moduleIns.createRecords(records,triggers,lar_id);//creating the records ,triggers and lar_id are optional , set null if not needed
         List<EntityResponse> responseIns =  responses.getEntityResponses();
         System.out.println( " Code:"+responses.getStatusCode());
         for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.createRecords();
		
	}
}
 
Update Records

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.crud.ZCRMRecord;    
import com.zoho.crm.library.crud.ZCRMTax;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void updateRecords() throws Exception {
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Invoices");//To get module instance,"Invoices" is the module api name
		Long recordid= 213123213123L;
		ZCRMRecord record=ZCRMRecord.getInstance("Invoices",recordid); //To get ZCRMRecord instance,"Invoices" is the module api name
         record.setFieldValue("Subject","Invoice"); //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
         record.setFieldValue("Account_Name",35240330246560L);//35240330246560L- account id
        
        /** Following methods are being used only by Inventory modules **/

         ZCRMInventoryLineItem lineItem=ZCRMInventoryLineItem.getInstance(null); //To get ZCRMInventoryLineItem instance
         lineItem.setDescription("Product_description"); //To set line item description
         lineItem.setDiscount(233.23); //To set line item discount
         lineItem.setListPrice(100.00); //To set line item list price
        
         ZCRMTax taxInstance1=ZCRMTax.getInstance("Sales Tax"); //To get ZCRMTax instance,"Sales Tax" is the tax name
         taxInstance1.setPercentage(2); //To set tax percentage
         taxInstance1.setValue(50); //To set tax value
         lineItem.addLineTax( taxInstance1); //To set line tax to line item
        
         ZCRMTax taxInstance2=ZCRMTax.getInstance("tax"); //To get ZCRMTax instance,"Tax" is the tax name
         taxInstance2.setPercentage(2); //To set tax percentage
         taxInstance2.setValue(50); //To set tax value
         lineItem.addLineTax( taxInstance2); //To set line tax to line item
         ZCRMRecord product =ZCRMRecord.getInstance("Products",35240330307001L);//35240330307001L -entity id, products is the module n me
         lineItem.setProduct(product); //To set product to line item
         lineItem.setQuantity(100.00); //To set product quantity to this line item
         record.addLineItem( lineItem);  //to add the line item to the record
         List<ZCRMRecord> records= Arrays.asList(record);
         List<CommonUtil.Trigger> triggers= Arrays.asList(CommonUtil.Trigger.workflow,CommonUtil.Trigger.approval,CommonUtil.Trigger.blueprint); //pushing the record to the array
         BulkAPIResponse responses= moduleIns.updateRecords(records,triggers);//updating the records ,triggers are optional , set null if not needed
         List<EntityResponse> responseIns =  responses.getEntityResponses();
         System.out.println( " Code:"+responses.getStatusCode());
         for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
        }
    }
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.updateRecords();
		
	}
}
 
Mass Update Records
//
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.crud.ZCRMRecord;    
import com.zoho.crm.library.crud.ZCRMTax;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void massUpdateRecords() throws Exception{  //In sdk version<2.0.0 the name of this method was updateRecords()
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module name
		List<Long> entityIds=Arrays.asList(3524033000000561002L,3524033000000539291L);
        List<CommonUtil.Trigger> triggers= Arrays.asList(CommonUtil.Trigger.workflow,CommonUtil.Trigger.approval,CommonUtil.Trigger.blueprint);
        String fieldname = "field_apiname";
		String fieldvalue = "value";
		BulkAPIResponse responses= moduleIns.massUpdateRecords(entityIds,fieldname,fieldvalue,triggers);//mass updating the records,triggers are optional , set null orset null if not needed
		List<EntityResponse>responseIns =  responses.getEntityResponses();
        System.out.println( " Code:"+responses.getStatusCode());
        for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
        }
	}
	
	
	public static void main(String[] args) throws Exception {
		TEST obj=new TEST();
		
		obj.massUpdateRecords();
	}
}
 
Upsert Records (Insert/Update)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void upsertRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//,"Leads" is the module api name
		ZCRMRecord record=ZCRMRecord.getInstance("Leads",null); //To get ZCRMRecord instance,invoices is the module api name
        record.setFieldValue("Subject","Invoice"); //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
        record.setFieldValue("Account_Name",35240330246560L);//35240330246560L- account id
       
       /** Following methods are being used only by Inventory modules **/

        ZCRMInventoryLineItem lineItem=ZCRMInventoryLineItem.getInstance(null); //To get ZCRMInventoryLineItem instance
        lineItem.setDescription("Product_description"); //To set line item description
        lineItem.setDiscount(233.23); //To set line item discount
        lineItem.setListPrice(100.00); //To set line item list price
       
        ZCRMTax taxInstance1=ZCRMTax.getInstance("Sales Tax"); //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
       
        ZCRMTax taxInstance2=ZCRMTax.getInstance("tax"); //To get ZCRMTax instance
        taxInstance2.setPercentage(2); //To set tax percentage
        taxInstance2.setValue(50); //To set tax value
        lineItem.addLineTax( taxInstance2); //To set line tax to line item
        ZCRMRecord product =ZCRMRecord.getInstance("Products",35240330307001L);//35240330307001L-entity id,products is the module name
        lineItem.setProduct(product); //To set product to line item
        lineItem.setQuantity(100.00); //To set product quantity to this line item
        record.addLineItem( lineItem);  //to add the line item to the record
        List<ZCRMRecord> records= Arrays.asList(record);
        List<CommonUtil.Trigger> triggers= Arrays.asList(CommonUtil.Trigger.workflow,CommonUtil.Trigger.approval,CommonUtil.Trigger.blueprint); //pushing the record to the array 
        List<String> duplicate_check_fields = new ArrayList();
        duplicate_check_fields.add("unique_field_name");
        BulkAPIResponse responses= moduleIns.upsertRecords(records,triggers,duplicate_check_fields);//upserting the records ,triggers are optional , ignore the parameter if not needed
        List<EntityResponse> responseIns =  responses.getEntityResponses();
        System.out.println( " Code:"+responses.getStatusCode());
        for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
       }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.upsertRecords();
		
	}
}
 
Delete Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void deleteRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		List<Long> entityIds=Arrays.asList(35240330561002L,35240330539291L);//35240330561002L,35240330539291L are the entity ids to delete
		BulkAPIResponse responses= moduleIns.deleteRecords(entityIds);//deleting the records
		List<EntityResponse> responseIns =  responses.getEntityResponses();
        System.out.println( " Code:"+responses.getStatusCode());
        for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.deleteRecords();
		
	}
}
 
Get List of Deleted Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getDeletedRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		int page=1;//page number 
		int perpage=200;//records per page
		String modifiedsince="2019-01-04T16:31:50+05:30";//to get records modified since this datetime in iso 8601 format
		BulkAPIResponse response=moduleIns.getDeletedRecords(modifiedsince,page,perpage);//to get the record ,if any parameter is not needed set null
		List<ZCRMTrashRecord> trashrecords=(List <ZCRMTrashRecord> )response.getData();
		for(ZCRMTrashRecord trashrecord : trashrecords){
			System.out.println(trashrecord.getEntityId());
			System.out.println(trashrecord.getType());
			System.out.println(trashrecord.getDisplayName());
			System.out.println(trashrecord.getDeletedTime());
			ZCRMUser creator=(trashrecord.getCreatedBy());
			if(creator!=null){
				System.out.println(creator.getId());
				System.out.println(creator.getFirstName());
			}
			ZCRMUser deletor=(trashrecord.getDeletedBy());
			if(deletor!=null){
				System.out.println(deletor.getId());
				System.out.println(deletor.getFirstName());
			}
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getDeletedRecords();
		
	}
}
 
Get List of Recycle Bin Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getRecycleBinRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String modifiedsince="2019-01-04T16:31:50+05:30";//to get records modified since this datetime in iso 8601 format
		BulkAPIResponse response=moduleIns.getRecycleBinRecords(modifiedsince);//to get the record ,if any parameter is not needed set null
		List<ZCRMTrashRecord> trashrecords=(List <ZCRMTrashRecord> )response.getData();
		for(ZCRMTrashRecord trashrecord : trashrecords){
			System.out.println(trashrecord.getEntityId());
			System.out.println(trashrecord.getType());
			System.out.println(trashrecord.getDisplayName());
			System.out.println(trashrecord.getDeletedTime());
			ZCRMUser creator=(trashrecord.getCreatedBy());
			if(creator!=null){
				System.out.println(creator.getId());
				System.out.println(creator.getFirstName());
			}
			ZCRMUser deletor=(trashrecord.getDeletedBy());
			if(deletor!=null){
				System.out.println(deletor.getId());
				System.out.println(deletor.getFirstName());
			}
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getRecycleBinRecords();
		
	}
}
 
Get List of Permanently Deleted Records

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void getPermanentlyDeletedRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String modifiedsince="2019-01-04T16:31:50+05:30";//to get records modified since this datetime in iso 8601 format
		BulkAPIResponse response=moduleIns.getPermanentlyDeletedRecords(modifiedsince);//to get the record ,if any parameter is not needed set null
		List<ZCRMTrashRecord> trashrecords=(List <ZCRMTrashRecord> )response.getData();
		for(ZCRMTrashRecord trashrecord : trashrecords){
			System.out.println(trashrecord.getEntityId());
			System.out.println(trashrecord.getType());
			System.out.println(trashrecord.getDisplayName());
			System.out.println(trashrecord.getDeletedTime());
			ZCRMUser creator=(trashrecord.getCreatedBy());
			if(creator!=null){
				System.out.println(creator.getId());
				System.out.println(creator.getFirstName());
			}
			ZCRMUser deletor=(trashrecord.getDeletedBy());
			if(deletor!=null){
				System.out.println(deletor.getId());
				System.out.println(deletor.getFirstName());
			}
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.getPermanentlyDeletedRecords();
		
	}
}
 
Search Records
Search Records by Word(Text)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void searchByText() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String searchtext="lead";//text to search with
		int page=1;//page number
		int perpage=50;//records per page		
		BulkAPIResponse response=moduleIns.searchByText(searchtext,page,perpage);//to get the record ,if any parameter(except text) is not needed set null
		List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
		for(ZCRMRecord record : records){
			System.out.println(record.getCreatedTime());
			System.out.println(record.getFieldValue("Company"));
			System.out.println(record.getLookupLabel());
			System.out.println(record.getModifiedTime());
			System.out.println(record.getModuleAPIName());
			List<ZCRMPriceBookPricing> pricings=(record.getPriceDetails());
			for(ZCRMPriceBookPricing pricing:pricings){
				   System.out.println(pricing.getId()); //To get the record's price_id
	               System.out.println(pricing.getToRange()); //To get the price_detail record's to_range
	               System.out.println(pricing.getFromRange()); //To get price_detail record's from_range
	               System.out.println(pricing.getDiscount());
			}
			ZCRMUser owner=(record.getOwner());
			if(owner!=null){
				System.out.println(owner.getId());
				System.out.println(owner.getFirstName());
			}
			ZCRMUser user1=(record.getModifiedBy());
			if(user1!=null){
				System.out.println(user1.getId());
				System.out.println(user1.getFirstName());
			}
			ZCRMUser user2=(record.getCreatedBy());
			if(user2!=null){
				System.out.println(user2.getId());
				System.out.println(user2.getFirstName());
			}
			System.out.println(record.getEntityId());
			ZCRMLayout layout=(record.getLayout());
			System.out.println(layout.getId());
			System.out.println(layout.getName());
			List<ZCRMInventoryLineItem> lineitems=(record.getLineItems());
			for(ZCRMInventoryLineItem lineItem :lineitems){
				 System.out.println(lineItem.getId()); //To get line_item id
	             System.out.println(lineItem.getListPrice()); //To get line_item list price
	             System.out.println(lineItem.getQuantity()); //To get line_item quantity
	             System.out.println(lineItem.getDescription()); //To get line_item description
	             System.out.println(lineItem.getTotal()); //To get line_item total amount
	             System.out.println(lineItem.getDiscount()); //To get line_item discount
	             System.out.println(lineItem.getDiscountPercentage()); //To get line_item discount percentage
	             System.out.println(lineItem.getTotalAfterDiscount()); //To get line_item amount after discount
	             System.out.println(lineItem.getTaxAmount()); //To get line_item tax amount
	             System.out.println(lineItem.getNetTotal()); //To get line_item net total amount
	             System.out.println(lineItem.getUnitPrice()); //To get line_item delete flag
	             System.out.println(lineItem.getProduct().getEntityId()); //To get line_item product's entity id
	             System.out.println(lineItem.getProduct().getLookupLabel()); //To get line_item product's lookup label
	             List <ZCRMTax> lineTaxs=lineItem.getLineTax(); //To get line_item's line_tax as array
	             for (ZCRMTax lineTax :lineTaxs )
	             {
	                 System.out.println(lineTax.getTaxName()); //To get line_tax name
	                 System.out.println(lineTax.getPercentage()); //To get line_tax percentage
	                 System.out.println(lineTax.getValue()); //To get line_tax value
	             }
			}
			HashMap<String, Object> data=(record.getData());
			for (Map.Entry<String, Object> entry : data.entrySet())  
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue()); 
			List <ZCRMTag> tags=record.getTagList();
			for (ZCRMTag tag :tags )
	        {
	            System.out.println(tag.getName()); //To get line_tax name
	            System.out.println(tag.getId()); //To get line_tax percentage
	        }
			List <ZCRMTax> taxes=record.getTaxList(); //To get line_item's line_tax as array
	        for (ZCRMTax tax :taxes )
	        {
	            System.out.println(tax.getTaxName()); //To get line_tax name
	            System.out.println(tax.getPercentage()); //To get line_tax percentage
	            System.out.println(tax.getValue()); //To get line_tax value
	        }
	        List <ZCRMEventParticipant> participants=record.getParticipants(); //To get line_item's line_tax as array
	        for (ZCRMEventParticipant participant :participants )
	        {
	        	 System.out.println(participant.getName()); //To get the record's participant name
	             System.out.println(participant.getEmail()); //To get the record's participant email
	             System.out.println(participant.getId()); //To get the record's participant id
	             System.out.println(participant.getType()); //To get the record's participant type
	             System.out.println(participant.isInvited()); //To check if the record's participant(s)) are invited or not
	             System.out.println(participant.getStatus()); //To get the record's participants' status
	        }
			System.out.println(record.getParticipants());
			HashMap<String, Object> properties=(record.getAllProperties());
			for (Map.Entry<String, Object> entry : properties.entrySet())  {
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue().toString()); 
	            
			}
			System.out.println(record.getProperty("$approved".toString()));
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.searchByText();
		
	}
}
 
Search Records by Phone

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void searchByPhone() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String phone="1121313213123";//phone to search with
		int page=1;//page number
		int perpage=50;//records per page		
		BulkAPIResponse response=moduleIns.searchByPhone(phone,page,perpage);//to get the record ,if any parameter(except phone) is not needed set null
		List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
		for(ZCRMRecord record : records){
			System.out.println(record.getCreatedTime());
			System.out.println(record.getFieldValue("Company"));
			System.out.println(record.getLookupLabel());
			System.out.println(record.getModifiedTime());
			System.out.println(record.getModuleAPIName());
			List<ZCRMPriceBookPricing> pricings=(record.getPriceDetails());
			for(ZCRMPriceBookPricing pricing:pricings){
				   System.out.println(pricing.getId()); //To get the record's price_id
	               System.out.println(pricing.getToRange()); //To get the price_detail record's to_range
	               System.out.println(pricing.getFromRange()); //To get price_detail record's from_range
	               System.out.println(pricing.getDiscount());
			}
			ZCRMUser owner=(record.getOwner());
			if(owner!=null){
				System.out.println(owner.getId());
				System.out.println(owner.getFirstName());
			}
			ZCRMUser user1=(record.getModifiedBy());
			if(user1!=null){
				System.out.println(user1.getId());
				System.out.println(user1.getFirstName());
			}
			ZCRMUser user2=(record.getCreatedBy());
			if(user2!=null){
				System.out.println(user2.getId());
				System.out.println(user2.getFirstName());
			}
			System.out.println(record.getEntityId());
			ZCRMLayout layout=(record.getLayout());
			System.out.println(layout.getId());
			System.out.println(layout.getName());
			List<ZCRMInventoryLineItem> lineitems=(record.getLineItems());
			for(ZCRMInventoryLineItem lineItem :lineitems){
				 System.out.println(lineItem.getId()); //To get line_item id
	             System.out.println(lineItem.getListPrice()); //To get line_item list price
	             System.out.println(lineItem.getQuantity()); //To get line_item quantity
	             System.out.println(lineItem.getDescription()); //To get line_item description
	             System.out.println(lineItem.getTotal()); //To get line_item total amount
	             System.out.println(lineItem.getDiscount()); //To get line_item discount
	             System.out.println(lineItem.getDiscountPercentage()); //To get line_item discount percentage
	             System.out.println(lineItem.getTotalAfterDiscount()); //To get line_item amount after discount
	             System.out.println(lineItem.getTaxAmount()); //To get line_item tax amount
	             System.out.println(lineItem.getNetTotal()); //To get line_item net total amount
	             System.out.println(lineItem.getUnitPrice()); //To get line_item delete flag
	             System.out.println(lineItem.getProduct().getEntityId()); //To get line_item product's entity id
	             System.out.println(lineItem.getProduct().getLookupLabel()); //To get line_item product's lookup label
	             List <ZCRMTax> lineTaxs=lineItem.getLineTax(); //To get line_item's line_tax as array
	             for (ZCRMTax lineTax :lineTaxs )
	             {
	                 System.out.println(lineTax.getTaxName()); //To get line_tax name
	                 System.out.println(lineTax.getPercentage()); //To get line_tax percentage
	                 System.out.println(lineTax.getValue()); //To get line_tax value
	             }
			}
			HashMap<String, Object> data=(record.getData());
			for (Map.Entry<String, Object> entry : data.entrySet())  
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue()); 
			List <ZCRMTag> tags=record.getTagList();
			for (ZCRMTag tag :tags )
	        {
	            System.out.println(tag.getName()); //To get line_tax name
	            System.out.println(tag.getId()); //To get line_tax percentage
	        }
			List <ZCRMTax> taxes=record.getTaxList(); //To get line_item's line_tax as array
	        for (ZCRMTax tax :taxes )
	        {
	            System.out.println(tax.getTaxName()); //To get line_tax name
	            System.out.println(tax.getPercentage()); //To get line_tax percentage
	            System.out.println(tax.getValue()); //To get line_tax value
	        }
	        List <ZCRMEventParticipant> participants=record.getParticipants(); //To get line_item's line_tax as array
	        for (ZCRMEventParticipant participant :participants )
	        {
	        	 System.out.println(participant.getName()); //To get the record's participant name
	             System.out.println(participant.getEmail()); //To get the record's participant email
	             System.out.println(participant.getId()); //To get the record's participant id
	             System.out.println(participant.getType()); //To get the record's participant type
	             System.out.println(participant.isInvited()); //To check if the record's participant(s)) are invited or not
	             System.out.println(participant.getStatus()); //To get the record's participants' status
	        }
			System.out.println(record.getParticipants());
			HashMap<String, Object> properties=(record.getAllProperties());
			for (Map.Entry<String, Object> entry : properties.entrySet())  {
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue().toString()); 
	            
			}
			System.out.println(record.getProperty("$approved".toString()));
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.searchByPhone();	
	}
}
 
Search Records by Email

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void searchByEmail() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String Email="xxx@zoho.com";//email to search with
		int page=1;//page number
		int perpage=50;//records per page		
		BulkAPIResponse response=moduleIns.searchByEmail(Email,page,perpage);//to get the record ,if any parameter(except email) is not needed set null
		List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
		for(ZCRMRecord record : records){
			System.out.println(record.getCreatedTime());
			System.out.println(record.getFieldValue("Company"));
			System.out.println(record.getLookupLabel());
			System.out.println(record.getModifiedTime());
			System.out.println(record.getModuleAPIName());
			List<ZCRMPriceBookPricing> pricings=(record.getPriceDetails());
			for(ZCRMPriceBookPricing pricing:pricings){
				   System.out.println(pricing.getId()); //To get the record's price_id
	               System.out.println(pricing.getToRange()); //To get the price_detail record's to_range
	               System.out.println(pricing.getFromRange()); //To get price_detail record's from_range
	               System.out.println(pricing.getDiscount());
			}
			ZCRMUser owner=(record.getOwner());
			if(owner!=null){
				System.out.println(owner.getId());
				System.out.println(owner.getFirstName());
			}
			ZCRMUser user1=(record.getModifiedBy());
			if(user1!=null){
				System.out.println(user1.getId());
				System.out.println(user1.getFirstName());
			}
			ZCRMUser user2=(record.getCreatedBy());
			if(user2!=null){
				System.out.println(user2.getId());
				System.out.println(user2.getFirstName());
			}
			System.out.println(record.getEntityId());
			ZCRMLayout layout=(record.getLayout());
			System.out.println(layout.getId());
			System.out.println(layout.getName());
			List<ZCRMInventoryLineItem> lineitems=(record.getLineItems());
			for(ZCRMInventoryLineItem lineItem :lineitems){
				 System.out.println(lineItem.getId()); //To get line_item id
	             System.out.println(lineItem.getListPrice()); //To get line_item list price
	             System.out.println(lineItem.getQuantity()); //To get line_item quantity
	             System.out.println(lineItem.getDescription()); //To get line_item description
	             System.out.println(lineItem.getTotal()); //To get line_item total amount
	             System.out.println(lineItem.getDiscount()); //To get line_item discount
	             System.out.println(lineItem.getDiscountPercentage()); //To get line_item discount percentage
	             System.out.println(lineItem.getTotalAfterDiscount()); //To get line_item amount after discount
	             System.out.println(lineItem.getTaxAmount()); //To get line_item tax amount
	             System.out.println(lineItem.getNetTotal()); //To get line_item net total amount
	             System.out.println(lineItem.getUnitPrice()); //To get line_item delete flag
	             System.out.println(lineItem.getProduct().getEntityId()); //To get line_item product's entity id
	             System.out.println(lineItem.getProduct().getLookupLabel()); //To get line_item product's lookup label
	             List <ZCRMTax> lineTaxs=lineItem.getLineTax(); //To get line_item's line_tax as array
	             for (ZCRMTax lineTax :lineTaxs )
	             {
	                 System.out.println(lineTax.getTaxName()); //To get line_tax name
	                 System.out.println(lineTax.getPercentage()); //To get line_tax percentage
	                 System.out.println(lineTax.getValue()); //To get line_tax value
	             }
			}
			HashMap<String, Object> data=(record.getData());
			for (Map.Entry<String, Object> entry : data.entrySet())  
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue()); 
			List <ZCRMTag> tags=record.getTagList();
			for (ZCRMTag tag :tags )
	        {
	            System.out.println(tag.getName()); //To get line_tax name
	            System.out.println(tag.getId()); //To get line_tax percentage
	        }
			List <ZCRMTax> taxes=record.getTaxList(); //To get line_item's line_tax as array
	        for (ZCRMTax tax :taxes )
	        {
	            System.out.println(tax.getTaxName()); //To get line_tax name
	            System.out.println(tax.getPercentage()); //To get line_tax percentage
	            System.out.println(tax.getValue()); //To get line_tax value
	        }
	        List <ZCRMEventParticipant> participants=record.getParticipants(); //To get line_item's line_tax as array
	        for (ZCRMEventParticipant participant :participants )
	        {
	        	 System.out.println(participant.getName()); //To get the record's participant name
	             System.out.println(participant.getEmail()); //To get the record's participant email
	             System.out.println(participant.getId()); //To get the record's participant id
	             System.out.println(participant.getType()); //To get the record's participant type
	             System.out.println(participant.isInvited()); //To check if the record's participant(s)) are invited or not
	             System.out.println(participant.getStatus()); //To get the record's participants' status
	        }
			System.out.println(record.getParticipants());
			HashMap<String, Object> properties=(record.getAllProperties());
			for (Map.Entry<String, Object> entry : properties.entrySet())  {
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue().toString()); 
	            
			}
			System.out.println(record.getProperty("$approved".toString()));
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.searchByEmail();
		
	}
}
 
Search Records by Criteria

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize(configurations_map);
	}
	public void searchByCriteria() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		String Criteria="Last_Name:starts_with:h";//criteria to search with
		int page=1;//page number
		int perpage=50;//records per page		
		BulkAPIResponse response=moduleIns.searchByCriteria(Criteria,page,perpage);//to get the record ,if any parameter(except Criteria) is not needed set null
		List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
		for(ZCRMRecord record : records){
			System.out.println(record.getCreatedTime());
			System.out.println(record.getFieldValue("Company"));
			System.out.println(record.getLookupLabel());
			System.out.println(record.getModifiedTime());
			System.out.println(record.getModuleAPIName());
			List<ZCRMPriceBookPricing> pricings=(record.getPriceDetails());
			for(ZCRMPriceBookPricing pricing:pricings){
				   System.out.println(pricing.getId()); //To get the record's price_id
	               System.out.println(pricing.getToRange()); //To get the price_detail record's to_range
	               System.out.println(pricing.getFromRange()); //To get price_detail record's from_range
	               System.out.println(pricing.getDiscount());
			}
			ZCRMUser owner=(record.getOwner());
			if(owner!=null){
				System.out.println(owner.getId());
				System.out.println(owner.getFirstName());
			}
			ZCRMUser user1=(record.getModifiedBy());
			if(user1!=null){
				System.out.println(user1.getId());
				System.out.println(user1.getFirstName());
			}
			ZCRMUser user2=(record.getCreatedBy());
			if(user2!=null){
				System.out.println(user2.getId());
				System.out.println(user2.getFirstName());
			}
			System.out.println(record.getEntityId());
			ZCRMLayout layout=(record.getLayout());
			System.out.println(layout.getId());
			System.out.println(layout.getName());
			List<ZCRMInventoryLineItem> lineitems=(record.getLineItems());
			for(ZCRMInventoryLineItem lineItem :lineitems){
				 System.out.println(lineItem.getId()); //To get line_item id
	             System.out.println(lineItem.getListPrice()); //To get line_item list price
	             System.out.println(lineItem.getQuantity()); //To get line_item quantity
	             System.out.println(lineItem.getDescription()); //To get line_item description
	             System.out.println(lineItem.getTotal()); //To get line_item total amount
	             System.out.println(lineItem.getDiscount()); //To get line_item discount
	             System.out.println(lineItem.getDiscountPercentage()); //To get line_item discount percentage
	             System.out.println(lineItem.getTotalAfterDiscount()); //To get line_item amount after discount
	             System.out.println(lineItem.getTaxAmount()); //To get line_item tax amount
	             System.out.println(lineItem.getNetTotal()); //To get line_item net total amount
	             System.out.println(lineItem.getUnitPrice()); //To get line_item delete flag
	             System.out.println(lineItem.getProduct().getEntityId()); //To get line_item product's entity id
	             System.out.println(lineItem.getProduct().getLookupLabel()); //To get line_item product's lookup label
	             List <ZCRMTax> lineTaxs=lineItem.getLineTax(); //To get line_item's line_tax as array
	             for (ZCRMTax lineTax :lineTaxs )
	             {
	                 System.out.println(lineTax.getTaxName()); //To get line_tax name
	                 System.out.println(lineTax.getPercentage()); //To get line_tax percentage
	                 System.out.println(lineTax.getValue()); //To get line_tax value
	             }
			}
			HashMap<String, Object> data=(record.getData());
			for (Map.Entry<String, Object> entry : data.entrySet())  
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue()); 
			List <ZCRMTag> tags=record.getTagList();
			for (ZCRMTag tag :tags )
	        {
	            System.out.println(tag.getName()); //To get line_tax name
	            System.out.println(tag.getId()); //To get line_tax percentage
	        }
			List <ZCRMTax> taxes=record.getTaxList(); //To get line_item's line_tax as array
	        for (ZCRMTax tax :taxes )
	        {
	            System.out.println(tax.getTaxName()); //To get line_tax name
	            System.out.println(tax.getPercentage()); //To get line_tax percentage
	            System.out.println(tax.getValue()); //To get line_tax value
	        }
	        List <ZCRMEventParticipant> participants=record.getParticipants(); //To get line_item's line_tax as array
	        for (ZCRMEventParticipant participant :participants )
	        {
	        	 System.out.println(participant.getName()); //To get the record's participant name
	             System.out.println(participant.getEmail()); //To get the record's participant email
	             System.out.println(participant.getId()); //To get the record's participant id
	             System.out.println(participant.getType()); //To get the record's participant type
	             System.out.println(participant.isInvited()); //To check if the record's participant(s)) are invited or not
	             System.out.println(participant.getStatus()); //To get the record's participants' status
	        }
			System.out.println(record.getParticipants());
			HashMap<String, Object> properties=(record.getAllProperties());
			for (Map.Entry<String, Object> entry : properties.entrySet())  {
	            System.out.println("field = " + entry.getKey() + ", Value = " + entry.getValue().toString()); 
	            
			}
			System.out.println(record.getProperty("$approved".toString()));
		}
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.searchByCriteria();
	}
}
Tags
Get Tags

import java.util.List;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
	public void getTags() throws Exception
	{
	    ZCRMModule moduleIns = ZCRMModule.getInstance("Contacts");// Contacts is the module API name
	    BulkAPIResponse response = moduleIns.getTags();// to get module tags
	    System.out.println(response.getStatusCode());
	    List<ZCRMTag> tagList = (List<ZCRMTag>)response.getData();
	    for (ZCRMTag tag : tagList)
	    { 
	    	System.out.println(tag.getId());// to get tag id
	    	System.out.println(tag.getName());// to get tag name
	
	        ZCRMUser createdBy = tag.getCreatedBy();
	        System.out.println(createdBy.getId());
	        System.out.println(createdBy.getFullName());
	
	        ZCRMUser modifiedBy = tag.getModifiedBy();
	        System.out.println(modifiedBy.getId());
	        System.out.println(modifiedBy.getFullName());
	
	        System.out.println(tag.getCreatedTime());
	        System.out.println(tag.getModifiedTime());
	    }
	    BulkAPIResponse.ResponseInfo info = response.getInfo();
	    System.out.println(info.getAllowedCount());// to get allowed count of this module
	    System.out.println(info.getRecordCount());// to get tag count of this module
	} 
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.getTags();
	}
}
 
Get Record Count of a Tag

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void getTagCount() throws Exception
	{
	    ZCRMModule moduleIns = ZCRMModule.getInstance("Leads");// Leads is the module API name
	    APIResponse response = moduleIns.getTagCount(538518L); // tag ID
	    ZCRMTag tagIns = (ZCRMTag)response.getData();
	    System.out.println(tagIns.getTagCount());
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.getTagCount();
	}
}
 
Create Tags

import java.util.ArrayList;
import java.util.List;

import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void createTags() throws Exception
	{
	    ZCRMModule moduleIns = ZCRMModule.getInstance("Contacts"); Contacts is the module API name
	    ZCRMTag tag;
	    List<ZCRMTag> tagList = new ArrayList<ZCRMTag>();
	
	    tag = ZCRMTag.getInstance();
	    tag.setName("tagname");
	
	    tagList.add(tag);
	
	    tag = ZCRMTag.getInstance();
	    tag.setName("tagname1");
	
	    tagList.add(tag);
	
	    BulkAPIResponse response = tags.createTags(tagList);
	    System.out.println(response.getStatusCode());
	    for (BulkAPIResponse.EntityResponse eResponse : response.getEntityResponses())
	    {
	    	System.out.println(eResponse.getMessage());
	    	System.out.println(eResponse.getStatus());
	        System.out.println(eResponse.getCode());
	        System.out.println(eResponse.getErrorDetails());
	        System.out.println(eResponse.getResponseJSON());
	        ZCRMTag tagIns = (ZCRMTag)eResponse.getData();
	        System.out.println(tagIns.getId());
	        System.out.println(tagIns.getName());
	
	        ZCRMUser createdBy = tagIns.getCreatedBy();
	        System.out.println(createdBy.getId());
	        System.out.println(createdBy.getFullName());
	
	        ZCRMUser modifiedBy = tagIns.getModifiedBy();
	        System.out.println(modifiedBy.getId());
	        System.out.println(modifiedBy.getFullName());
	
	        System.out.println(tagIns.getCreatedTime());
	        System.out.println(tagIns.getModifiedTime());
	    }
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.createTags();
	}
}
 
Update Multiple Tags

import java.util.ArrayList;
import java.util.List;

import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.exception.ZCRMException;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void updateTags() throws ZCRMException
	{
	    /** Multiple Tag updates */
	    ZCRMModule modulesIns = ZCRMModule.getInstance("Contacts"); // Contacts is the module API name
	    List<ZCRMTag> tags = new ArrayList<ZCRMTag>();
	    ZCRMTag tag1 = ZCRMTag.getInstance(5385188003L); //tag ID
	    tag1.setName("Name7");
	    ZCRMTag tag2 = ZCRMTag.getInstance(538548004L); // tag ID
	    tag2.setName("Name8");
	    tags.add(tag1);
	    tags.add(tag2);
	    BulkAPIResponse response = modulesIns.updateTags(tags); //tags - list of ZCRMTag instances filled with required data for update.
	    System.out.println(response.getStatusCode());
	    for (BulkAPIResponse.EntityResponse eResponse : response.getEntityResponses())
	    {
	        System.out.println(eResponse.getMessage());
	        System.out.println(eResponse.getStatus());
	        System.out.println(eResponse.getCode());
	        System.out.println(eResponse.getErrorDetails());
	        System.out.println(eResponse.getResponseJSON());
	        ZCRMTag tag = (ZCRMTag)eResponse.getData();
	        System.out.println(tag.getId());
	        System.out.println(tag.getName());
	
	        ZCRMUser createdBy = tag.getCreatedBy();
	        System.out.println(createdBy.getId());
	        System.out.println(createdBy.getFullName());
	
	        ZCRMUser modifiedBy = tag.getModifiedBy();
	        System.out.println(modifiedBy.getId());
	        System.out.println(modifiedBy.getFullName());
	
	        System.out.println(tag.getCreatedTime());
	        System.out.println(tag.getModifiedTime());
	
	    }
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.updateTags();
	}
}
 
Add Tags to Multiple Records

import java.util.ArrayList;
import java.util.List;

import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.exception.ZCRMException;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void addTagsToMultipleRecords() throws ZCRMException
{
	    ZCRMModule module = ZCRMModule.getInstance("Contacts"); // Contacts is the module API name
	    List<String> tagNames = new ArrayList<String>();
	    tagNames.add("N3"); //N3 is the name of the Tag
	    tagNames.add("N4"); //N4 is the name of the Tag
	    List<Long> recordIds = new ArrayList<Long>();
	    recordIds.add(53851044L); //53851044L is the record ID
	    recordIds.add(538513L);
	    recordIds.add(538513L);
	    recordIds.add(538518L);
	    recordIds.add(539331L);
	    recordIds.add(530001L);
	    
	    BulkAPIResponse response = module.addTagsToRecords(recordIds, tagNames);//recordIds list of record id, tagNames list of tag names
	    System.out.println(response.getStatusCode());
	    for (BulkAPIResponse.EntityResponse eResponse : response.getEntityResponses())
	    {
	    	System.out.println(eResponse.getMessage());
	        System.out.println(eResponse.getStatus());
	        System.out.println(eResponse.getCode());
	        System.out.println(eResponse.getErrorDetails());
	        System.out.println(eResponse.getResponseJSON());
	        ZCRMRecord record = (ZCRMRecord)eResponse.getData();
	        System.out.println(record.getModuleAPIName());
	        System.out.println(record.getEntityId());
	        for (String tagName : record.getTagNames())
	        {
	            System.out.println(tagName);
	        }
	    }
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.addTagsToMultipleRecords();
	}
}
 
Remove Tags from Multiple Records

import java.util.ArrayList;
import java.util.List;

import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.exception.ZCRMException;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Module 
{
    public Module() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void removeTagsFromMultipleRecords() throws ZCRMException
	{
	    ZCRMModule module = ZCRMModule.getInstance("Contacts"); //Contacts is the module API name
	    List<String> tagNames = new ArrayList<String>();
	    tagNames.add("N3"); //N3 is the name of the Tag
	    tagNames.add("N4"); //N4 is the name of the Tag
	    List<Long> recordIds = new ArrayList<Long>();
	    recordIds.add(538713044L); // 538713044L is the record ID
	    recordIds.add(538513043L);
	    recordIds.add(538534042L);
	    recordIds.add(538519558L);
	    recordIds.add(5384846931L);
	    recordIds.add(5385184401L);
	    BulkAPIResponse response = module.removeTagsFromRecords(recordIds, tagNames);//recordIds is the list of record IDs, tagNames is the list of tag names
	    System.out.println(response.getStatusCode());
	    for (BulkAPIResponse.EntityResponse eResponse : response.getEntityResponses())
	    {
	    	System.out.println(eResponse.getMessage());
	        System.out.println(eResponse.getStatus());
	        System.out.println(eResponse.getCode());
	        System.out.println(eResponse.getErrorDetails());
	        System.out.println(eResponse.getResponseJSON());
	        ZCRMRecord record = (ZCRMRecord)eResponse.getData();
	        System.out.println(record.getModuleAPIName());
	        System.out.println(record.getEntityId());
	        for (String tagName : record.getTagNames())
	        {
	            System.out.println(tagName);
	        }
	    }
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Module obj = new Module();
		obj.removeTagsFromMultipleRecords();
	}
}