Java SDK Samples - Tag Operations

Tags
Update a Specific Tag
              
              
import java.util.ArrayList;
import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
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 Tag 
{
    public Tag() throws Exception {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void updateTag() throws ZCRMException {
	    ZCRMTag tagIns = ZCRMTag.getInstance(538518000001L, "Leads");//538518000001L is the tag ID, Leads is the Module API name
	    tagIns.setName("updatedName");
	    APIResponse response = tagIns.update();
	    ZCRMTag tag = (ZCRMTag)response.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());

        System.out.println(response.getMessage());
        System.out.println(response.getStatus());
        System.out.println(response.getResponseJSON());
	}
    
	public static void main(String[] args) throws Exception {    
		Tag obj = new Tag();
		obj.updateTag();
	}
}

 
Delete a Tag
              
              
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.exception.ZCRMException;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;

public class Tag 
{
    public Tag() throws Exception{
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void deleteTag() throws ZCRMException{
        ZCRMTag tag = ZCRMTag.getInstance(53851701L); //53851701L is the ID of the tag to be deleted
        APIResponse response = tag.delete();
        System.out.println(response.getMessage());
        System.out.println(response.getStatus());
        System.out.println(response.getStatusCode());
        System.out.println(response.getResponseJSON());
    }
    
public static void main(String[] args) throws Exception {    
        Tag obj = new Tag();
        obj.deleteTag();
    }
}
 
Merge Tags
              
              
import com.zoho.crm.library.api.response.APIResponse;
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 Tag 
{
    public Tag() throws Exception
    {
        ZCRMRestClient.initialize(configurations_map);
    }
    
    public void mergeTag() throws ZCRMException
	{
	    ZCRMTag tagIns = ZCRMTag.getInstance(538518672725L); // tag ID
	    ZCRMTag tagToBeMerged = ZCRMTag.getInstance(538502731001L); //conflict tag ID
	    APIResponse response = tagIns.merge(tagToBeMerged);
	
	    ZCRMTag tag = (ZCRMTag)response.getData();
	    System.out.println(tag.getId());

        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());
	
	    System.out.println(response.getMessage());
	    System.out.println(response.getStatus());
	    System.out.println(response.getStatusCode());
	    System.out.println(response.getResponseJSON());
	}
    
	public static void main(String[] args) throws Exception 
    {    
		Tag obj = new Tag();
		obj.mergeTag();
	}
}