Android SDK Samples - Tags Operations

Get All Tags
          
          
ZCRMSDKUtil.getModuleDelegate("Leads").getTags(object : DataCallback<BulkAPIResponse, List<ZCRMTag>>
    //Leads is the module API name
    {
                    override fun completed(response: BulkAPIResponse, tags: List<ZCRMTag>) {
                        println("${response.responseJSON}")
                    }
    
                    override fun failed(exception: ZCRMException) {
                        println("Throws Exception : $exception")
                    }
                })
 
Create Tags
          
          
val moduleDelegate = ZCRMSDKUtil.getModuleDelegate("Contacts")

//create new tags using newTag(), and add them to tagList
val tag1 = moduleDelegate.newTag("Followup")
val tag2 = moduleDelegate.newTag("Important")
val tagList = listOf<ZCRMTag>(tag1,tag2)

//call createTags() by passing the tagList as a parameter 
moduleDelegate.createTags(tagList,object:DataCallback<BulkAPIResponse,List<ZCRMTag>>
{
   override fun completed(response: BulkAPIResponse, zcrmentity: List<ZCRMTag>) {
       println("${response.responseJSON}")
   }

   override fun failed(exception: ZCRMException) {
       println("Throws Exception : $exception")
   }

})
 
Get Record Count of a Specific Tag
          
          
//$tag object is of ZCRMTag

//call getRecordCount() using $tag object
$tag.getRecordCount( object : DataCallback<APIResponse,Int>
    {
         override fun completed(response: APIResponse, recordCount: Int)
         {
             println("${response.responseJSON}")
          }

         override fun failed(exception: ZCRMException)
         {
            println("Throws Exception : $exception")
          }
    })
 
Merge Tags
          
          
//$tags object is of ZCRMTag                   
val tag1 = $tags[0] //tag1 - "Important" tag
val tag2 = $tags[1] //tag2 - "Mark as Important" tag

//call merge() using tag1, and pass tag2 as parameter to it
tag1.merge(tag2, object : DataCallback<APIResponse, ZCRMTag>{
   override fun completed(response: APIResponse, tag: ZCRMTag) {
       println("${response.responseJSON}")
    }

    override fun failed(exception: ZCRMException) {
      println("Throws Exception1 : $exception")
   }

})
 
Update a Tag
          
          
//$tag object is of ZCRMTag

$tag.name = "To Followup" //update the name of the tag using $tag object

//call update() using $tag object
$tag.update(object: DataCallback<APIResponse, ZCRMTag>
       {
           override fun completed(response: APIResponse, tag: ZCRMTag) {
               println("${response.responseJSON}")
           }

           override fun failed(exception: ZCRMException) {
               println("Throws Exception : $exception")
           }
     })
 
Update Tags
          
          
val tagsList = arrayListOf<ZCRMTag>()

//$tag1 and $tag2 objects are of ZCRMTag

//define the new values to the tags and add them to tagsList

$tag1.name = "To Followup" //updating the tag name as "To Followup"
tagsList.add($tag1) //add tag1 to tagsList

$tag2.name = "Approved" //updating the tag name as "Approved"
tagsList.add($tag2) //add tag2 to tagsList

//$moduleDelegate object is of ZCRMModuleDelegate

//call updateTags() using $moduleDelegate object by passing the tagsList as a parameter to it

$moduleDelegate.updateTags(tagsList, object : DataCallback<BulkAPIResponse, List<ZCRMTag>>{
    override fun completed(response: BulkAPIResponse, zcrmTags: List<ZCRMTag>) {
        println("${response.responseJSON}")
   }
   override fun failed(exception: ZCRMException) {
       println("Throws Exception: $exception")
   }
})
 
Delete a Tag
          
          
//$tag object is of ZCRMTag
      //call delete() using the tag object
      $tag.delete(object : ResponseCallback<APIResponse>{
        override fun completed(response: APIResponse) {
            println("${response.responseJSON}")
         }

        override fun failed(exception: ZCRMException) {
             println("Throws Exception : $exception")
         }

      })
 
Add Tags to a Record
          
          
val tagsList = listOf("To Followup", "Approved")//"To Followup" and "Approved" are the tags added to tagsList

//$record object is of ZCRMRecord

//call addTags() using $record object by passing tagsList as a parameter to it

$record.addTags(tagsList,object: DataCallback<APIResponse, ZCRMRecord>{
    override fun completed(response: APIResponse, record: ZCRMRecord) {
        println("${response.responseJSON}")
    }

    override fun failed(exception: ZCRMException) {
        println("Throws Exception: $exception")
    }

})
 
Add Tags to Records
          
          
val moduleDelegate = ZCRMSDKUtil.getModuleDelegate("Contacts")

val tagsList = listOf("To Followup", "Approved") //list of tag names

val recordsList = arrayListOf<ZCRMRecord>() //list of records

//$record1 and $record2 objects are of ZCRMRecord

recordsList.add($record1)
recordsList.add($record2)

//call addTags() by passing the recordsList and tagsList as parameters to it

moduleDelegate.addTags(recordsList, tagsList, object: DataCallback<BulkAPIResponse, List<ZCRMRecord>>{
    override fun completed(response: BulkAPIResponse, zcrmentity: List<ZCRMRecord>) {
        println("${response.responseJSON}")
    }

    override fun failed(exception: ZCRMException) {
       println("Throws Exception: $exception")
    }

})
 
Remove Tags from a Record
          
          
val tagsList = listOf("To Followup", "Approved") //"To Followup" and "Approved" are the tags added to tagsList

//$record object is of ZCRMRecord

//call removeTags() using $record object by passing the tagsList as a parameter to it

$record.removeTags(tagsList,object:DataCallback<APIResponse,ZCRMRecord>{
    override fun completed(response: APIResponse, zcrmentity: ZCRMRecord) {
        println("${response.responseJSON}")
    }

    override fun failed(exception: ZCRMException) {
        println("Throws Exception: $exception")
    }

})
 
Remove Tags from Records
          
          
val moduleDelegate = ZCRMSDKUtil.getModuleDelegate("Contacts")

val tagsList = listOf("To Followup", "Approved") // list of tag names

val recordsList = arrayListOf<ZCRMRecord>()
//$record1 and $record1 objects are of ZCRMRecord
recordsList.add($record1)
recordsList.add($record2)

//call removeTags() by passing recordsList and tagsList as parameters

moduleDelegate.removeTags(recordsList, tagsList, object: DataCallback<BulkAPIResponse, List<ZCRMRecord>>{
    override fun completed(response: BulkAPIResponse, zcrmentity: List<ZCRMRecord>) {
        println("${response.responseJSON}")
    }

    override fun failed(exception: ZCRMException) {
        println("Throws Exception: $exception")
    }

})