Java SDK Samples - Organization Operations
Users
Get User Details
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getUser() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
APIResponse response = client.getOrganizationInstance().getUser(35240330411002L);//35240330411002L is user id
ZCRMUser userInstance =(ZCRMUser )response.getData();
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getUser();
}
}
Get All Users
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllUsers() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
String modifiedSince="2018-09-15T15:53:00+05:30";//can be left null
int page=1;//page number, can be left null
int per_page=5;//users per page,can be left null
BulkAPIResponse response = client.getOrganizationInstance().getAllUsers();
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
for(ZCRMUser userInstance : users ){
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllUsers();
}
}
Get All Active Users
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllActiveUsers() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
int page=1;//page number, can be left null
int per_page=5;//users per page,can be left null
BulkAPIResponse response = client.getOrganizationInstance().getAllActiveUsers( page, per_page);
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
for(ZCRMUser userInstance : users ){
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllActiveUsers();
}
}
Get All Deactivated Users
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllInActiveUsers() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
int page=1;//page number, can be left null
int per_page=5;//users per page,can be left null
BulkAPIResponse response = client.getOrganizationInstance().getAllInActiveUsers( page, per_page);
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
for(ZCRMUser userInstance : users ){
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllInActiveUsers();
}
}
Get All Active & Confirmed Users
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllActiveConfirmedUsers() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
int page=1;//page number, can be left null
int per_page=5;//users per page,can be left null
BulkAPIResponse response = client.getOrganizationInstance().getAllActiveConfirmedUsers( page, per_page);
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
for(ZCRMUser userInstance : users ){
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllActiveConfirmedUsers();
}
}
Get All Admin Users
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllAdminUsers() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
int page=1;//page number, can be left null
int per_page=5;//users per page,can be left null
BulkAPIResponse response = client.getOrganizationInstance().getAllAdminUsers( page, per_page);
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
for(ZCRMUser userInstance : users ){
System.out.println( userInstance.getId());//to get the user id
System.out.println( userInstance.getCountry());//to get the country of the user
ZCRMRole role=(ZCRMRole)userInstance.getRole();//to get the role of the user in form of ZCRMRole instance
System.out.println(role.getId());//to get the role id
System.out.println(role.getName());//to get the role name
System.out.println(userInstance.getCity());//to get the city of the user
System.out.println(userInstance.getNameFormat());// to get the name format of the user
System.out.println(userInstance.getLanguage());//to get the language of the user
System.out.println(userInstance.getLocale());//to get the locale of the user
System.out.println(userInstance.getAlias());//to get the alias of the user
System.out.println(userInstance.getStreet());//to get the street name of the user
System.out.println(userInstance.getState());//to get the state of the user
System.out.println(userInstance.getCountry());
System.out.println(userInstance.getCountryLocale());//to get the country locale of the user
System.out.println(userInstance.getFax());//to get the fax number of the user
System.out.println(userInstance.getFullName());//to get the first name of the user
System.out.println(userInstance.getEmailId());//to get the email id of the user
System.out.println(userInstance.getZip());//to get the zip code of the user
System.out.println(userInstance.getWebsite());//to get the website of the user
System.out.println(userInstance.getTimeFormat());//to get the time format of the user
ZCRMProfile profile= (ZCRMProfile)userInstance.getProfile();//to get the user's profile in form of ZCRMProfile
System.out.println(profile.getId());//to get the profile id
System.out.println(profile.getName());//to get the name of the profile
System.out.println(userInstance.getMobile());//to get the mobile number of the user
System.out.println(userInstance.getLastName());//to get the last name of the user
System.out.println(userInstance.getTimeZone());//to get the time zone of the user
System.out.println(userInstance.getZUId());//to get the zoho user id of the user
System.out.println(userInstance.isConfirmed());//to check whether it is a confirmed user
System.out.println(userInstance.getFullName());//to get the full name of the user
System.out.println(userInstance.getPhone());//to get the phone number of the user
System.out.println(userInstance.getDateOfBirth());//to get the date of birth of the user
System.out.println(userInstance.getDateFormat());//to get the date format
System.out.println(userInstance.getStatus());//to get the status of the user
ZCRMUser reportingto=(ZCRMUser) userInstance.getReportingTo();
if(reportingto!=null){
System.out.println(reportingto.getId());
System.out.println(reportingto.getFullName());
}
ZCRMUser modified=(ZCRMUser) userInstance.getModifiedBy();
if(modified!=null){
System.out.println(modified.getId());
System.out.println(modified.getFullName());
}
ZCRMUser createdby=(ZCRMUser) userInstance.getCreatedBy();
if(createdby!=null){
System.out.println(createdby.getId());
System.out.println(createdby.getFullName());
}
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllAdminUsers();
}
}
Add a User
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void addUser() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
ZCRMUser user=ZCRMUser.getInstance(null);//null is passed to the entity id
user.setFirstName("firstname");
user.setFullName("firstname lastname");
user.setLastName("lastname");
user.setEmailId("abc@zoho.com");
ZCRMRole role=ZCRMRole.getInstance(35240330026005L, "CEO");//35240330026005L-entity id,"CEO" is the role name
user.setRole(role);
ZCRMProfile profile=ZCRMProfile.getInstance(35240330324525L,"test11");//35240330324525L-entity id,"test11" -profile name
user.setProfile(profile);
ZCRMOrganization org=client.getOrganizationInstance();
APIResponse response=org.addUser(user);
System.out.println("HTTP status code"+response.getStatusCode());
System.out.println("Status"+response.getStatus());
System.out.println("message"+response.getMessage());
System.out.println("details"+response.getResponseJSON());
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.addUser();
}
}
Update User Details
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void updateUser() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
ZCRMUser user=ZCRMUser.getInstance(35240330411002L);//35240330411002L is user id
user.setFirstName("firstname");
user.setFullName("firstname lastname");
user.setLastName("lastname");
ZCRMOrganization org=client.getOrganizationInstance();
APIResponse response=org.updateUser(user);
System.out.println("HTTP status code "+response.getStatusCode());
System.out.println("Status "+response.getStatus());
System.out.println("message "+response.getMessage());
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.updateUser();
}
}
Delete User Details
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void deleteUser() throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
ZCRMOrganization org=client.getOrganizationInstance();
APIResponse response=org.deleteUser(35240330411002L);//35240330411002L is user id
System.out.println("HTTP status code "+response.getStatusCode());
System.out.println("Status "+response.getStatus());
System.out.println("message "+response.getMessage());
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.deleteUser();
}
}
Profiles
Get All Profiles
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllProfiles()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
BulkAPIResponse response=client.getOrganizationInstance().getAllProfiles();
List<ZCRMProfile> profiles = (List<ZCRMProfile>) response.getData();
for(ZCRMProfile profile :profiles){
System.out.println( profile.getId());//to get the id of the profile
System.out.println( profile.getName());//to get the name of the profile
System.out.println( profile.getCreatedTime());//to get the created time of the profile
System.out.println( profile.getModifiedTime());//to get the modified time of the profile
ZCRMUser userInstance= (ZCRMUser)profile.getModifiedBy();//to get the user who modified the profile
if( userInstance!=null){
System.out.println(userInstance.getId());//to get the user id
System.out.println(userInstance.getFullName());//to get the user name
}
System.out.println( profile.getDescription());//to get the profile description
ZCRMUser userInstance2= profile.getCreatedBy();//to get the user who created the profile
if( userInstance2!=null){
System.out.println( userInstance2.getId());//to get the profile id
System.out.println( userInstance2.getFullName());//to get the profile name
}
System.out.println( profile.getCategory());//to get the category of the profile
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllProfiles();
}
}
Get Profile Data
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getProfile()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
APIResponse response=client.getOrganizationInstance().getProfile(35240330026014L);//35240330026014L-profile id
ZCRMProfile profile = (ZCRMProfile) response.getData();
System.out.println( profile.getId());//to get the id of the profile
System.out.println( profile.getName());//to get the name of the profile
System.out.println( profile.getCreatedTime());//to get the created time of the profile
System.out.println( profile.getModifiedTime());//to get the modified time of the profile
ZCRMUser userInstance= (ZCRMUser)profile.getModifiedBy();//to get the user who modified the profile
if( userInstance!=null){
System.out.println(userInstance.getId());//to get the user id
System.out.println(userInstance.getFullName());//to get the user name
}
System.out.println( profile.getDescription());//to get the profile description
ZCRMUser userInstance2= profile.getCreatedBy();//to get the user who created the profile
if( userInstance2!=null){
System.out.println( userInstance2.getId());//to get the profile id
System.out.println( userInstance2.getFullName());//to get the profile name
}
System.out.println( profile.getCategory());//to get the category of the profile
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getProfile();
}
}
Roles
Get All Roles
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllRoles()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
BulkAPIResponse response=client.getOrganizationInstance().getAllRoles();
List<ZCRMRole> roles = (List<ZCRMRole>) response.getData();
for(ZCRMRole role :roles){
System.out.println( role.getName());//to get the role name
System.out.println( role.getId());//to get the role id
ZCRMRole role1=(ZCRMRole) role.getReportingTo();//to get the user name to whom user of this role will report to
if(role1!=null){
System.out.println(role1.getId());
System.out.println(role1.getName());
}
System.out.println(role.getLabel());//to get the display label of the role
System.out.println(role.getAdminUser());//to check whether it is the administrator role
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllRoles();
}
}
Get Role Data
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getRoles()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
APIResponse response=client.getOrganizationInstance().getRole(35240330026005L);//35240330026005L role id
ZCRMRole role = (ZCRMRole)response.getData();
System.out.println(role.getName());//to get the role name
System.out.println(role.getId());//to get the role id
ZCRMRole role1=(ZCRMRole) role.getReportingTo();//to get the user name to whom user of this role will report to
if(role1!=null){
System.out.println(role1.getId());
System.out.println(role1.getName());
}
System.out.println(role.getLabel());//to get the display label of the role
System.out.println(role.getAdminUser());//to check whether it is the administrator role
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getRoles();
}
}
Organization Taxes
Get All Organization Taxes
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getAllTaxes()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
BulkAPIResponse response=client.getOrganizationInstance().getAllTaxes();
List<ZCRMOrgTax> orgtaxes=(List<ZCRMOrgTax>) response.getData();
for(ZCRMOrgTax orgtax: orgtaxes){
System.out.println(orgtax.getId());
System.out.println(orgtax.getName());
System.out.println(orgtax.getDisplayName());
System.out.println(orgtax.getValue());
System.out.println(orgtax.getSequence());
}
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getAllTaxes();
}
}
Get Specific Organization Tax
import java.util.List;
import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;
public class Org{
public Org() throws Exception{
ZCRMRestClient.initialize(configurations_map);
}
public void getTax()throws Exception{
ZCRMRestClient client = ZCRMRestClient.getInstance();
APIResponse response=client.getOrganizationInstance().getTax(35240330021001L);//35240330021001L-tax id
ZCRMOrgTax orgtax=(ZCRMOrgTax) response.getData();
System.out.println(orgtax.getId());
System.out.println(orgtax.getName());
System.out.println(orgtax.getDisplayName());
System.out.println(orgtax.getValue());
System.out.println(orgtax.getSequence());
}
public static void main(String[] args) throws Exception {
Org obj=new Org();
obj.getTax();
}
}
Variables
Get Variables
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.crm.library.crud.ZCRMVariable;
import com.zoho.crm.library.crud.ZCRMVariableGroup;
public class Org {
public Org() throws Exception {
ZCRMRestClient.initialize(configurations_map);
}
public void getVariables() throws Exception {
ZCRMOrganization org = ZCRMOrganization.getInstance();
BulkAPIResponse response = org.getVariables();
List <ZCRMVariable> variables = (List <ZCRMVariable>) response.getData();
for (ZCRMVariable variable: variables) {
System.out.println(variable.getId());
System.out.println(variable.getApiName());
System.out.println(variable.getName());
System.out.println(variable.getDescription());
System.out.println(variable.getType());
System.out.println(variable.getValue());
System.out.println(variable.getVariableGroup().getId());
System.out.println(variable.getVariableGroup().getApiName());
}
}
public static void main(String[] args) throws Exception {
Org obj = new Org();
Org.getVariables();
}
}
Get Variable Groups
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.crm.library.crud.ZCRMVariable;
import com.zoho.crm.library.crud.ZCRMVariableGroup;
public class Org {
public Org() throws Exception {
ZCRMRestClient.initialize(configurations_map);
}
public void getVariableGroups() throws Exception{
ZCRMOrganization org = ZCRMOrganization.getInstance();
BulkAPIResponse response=org.getVariableGroups();
List<ZCRMVariableGroup> variablegrps = (List<ZCRMVariableGroup>) response.getData();
for(ZCRMVariableGroup variablegrp : variablegrps){
System.out.println(variablegrp.getId());
System.out.println(variablegrp.getApiName());
System.out.println(variablegrp.getName());
System.out.println(variablegrp.getDescription());
System.out.println(variablegrp.getDisplayLabel());
}
}
public static void main(String[] args) throws Exception {
Org obj = new Org();
Org.getVariables();
}
}
Create Variables
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.crm.library.crud.ZCRMVariable;
import com.zoho.crm.library.crud.ZCRMVariableGroup;
public class Org {
public Org() throws Exception {
ZCRMRestClient.initialize(configurations_map);
}
public void createVariables() throws Exception {
ZCRMVariable ins = ZCRMVariable.getInstance();
ZCRMVariableGroup gr = ZCRMVariableGroup.getInstance();
gr.setApiName("General");
gr.setName("General");
ins.setVariableGroup(gr);
ins.setName("Variabadasdlsadetest1");
ins.setApiName("Variasdasddabletest1");
ins.setDescription("asdad");
ins.setType("integer");
ins.setValue("35");
ArrayList list = new ArrayList();
list.add(ins);
ZCRMOrganization zo = ZCRMOrganization.getInstance();
BulkAPIResponse response = zo.createVariables(list);
List <EntityResponse> responseIns = response.getEntityResponses();
System.out.println(" Code:" + response.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 {
Org obj = new Org();
Org.createVariables();
}
}
Update Variables
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.crm.library.crud.ZCRMVariable;
import com.zoho.crm.library.crud.ZCRMVariableGroup;
public class Org {
public Org() throws Exception {
ZCRMRestClient.initialize(configurations_map);
}
public void updateVariables() throws Exception{
ZCRMVariable ins=ZCRMVariable.getInstance();
ZCRMVariableGroup gr = ZCRMVariableGroup.getInstance();
gr.setApiName("General");
gr.setName("General");
ins.setVariableGroup(gr);
ins.setName("Variabadasdlasasdsadetest1");
ins.setApiName("Variasasddasdasddabletest1");
ins.setDescription("asdad");
ins.setType("integer");
ins.setId(3524033000003006002L);
ins.setValue("35");
ArrayList list=new ArrayList();
list.add(ins);
ZCRMOrganization zo=ZCRMOrganization.getInstance();
BulkAPIResponse response=zo.updateVariables(list);
List<EntityResponse> responseIns = response.getEntityResponses();
System.out.println( " Code:"+response.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 {
Org obj = new Org();
Org.updateVariables();
}
}