Android SDK Samples - CRM Variables Operations
ZCRMSDKUtil.getVariables(object : DataCallback<BulkAPIResponse, List<ZCRMVariable>>{
override fun completed(response: BulkAPIResponse, variables: List<ZCRMVariable>) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//call getVariable() by passing the variableId and groupId as parameters to it
//id - ID of the variable.
//groupId - Group ID of the variable group.
ZCRMSDKUtil.getVariable(371xxx007, 371xxx005, object : DataCallback<APIResponse, ZCRMVariable>{
// 371xxx007 is the variable id & 371xxx005 is the groud id
override fun completed(response: APIResponse, variable: ZCRMVariable) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//call getVariable() by passing the apiName and groupId as parameters to it
//apiName - APIName of the variable.
//groupId - Group ID of the variable group.
ZCRMSDKUtil.getVariable("Variable2", 371xxx005, object : DataCallback<APIResponse, ZCRMVariable>{
//Variable2 is the API name of the variable & 371xxx005 is the groupId
override fun completed(response: APIResponse, variable: ZCRMVariable) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//call getVariable() by passing the id and groupAPIName as parameters to it.
//id - ID of the variable.
//groupAPIName - Group APIName of the variable group.
ZCRMSDKUtil.getVariable(371xxx007,"Group2", object : DataCallback<APIResponse, ZCRMVariable>{
//371xxx007 is the variable id & Group2 is the group API name.
override fun completed(response: APIResponse, variable: ZCRMVariable) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//Call getVariable() by passing the apiName and groupAPIName as parameters to it.
//apiName - APIName of the variable.
//groupAPIName - Group APIName of the variable group.
ZCRMSDKUtil.getVariable("Variable2","Group2", object : DataCallback<APIResponse, ZCRMVariable>{
//Variable2 is the apiName & Group2 is the groupAPIName
override fun completed(response: APIResponse, variable: ZCRMVariable) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
ZCRMSDKUtil.getVariableGroups(object : DataCallback<BulkAPIResponse,List<ZCRMVariableGroup>>{
override fun completed(response: BulkAPIResponse, variableGroups: List<ZCRMVariableGroup>) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//call getVariableGroup() by passing the apiName as a parameter to it.
//apiName - APIName of the variable group.
ZCRMSDKUtil.getVariableGroup("Group4", object : DataCallback<APIResponse, ZCRMVariableGroup>{
//Group4 is the apiName
override fun completed(response: APIResponse, variable: ZCRMVariableGroup) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//call getVariableGroup() by passing the id as a parameter to it.
//id - ID of the variable group.
ZCRMSDKUtil.getVariableGroup(371xxx003, object : DataCallback<APIResponse, ZCRMVariableGroup>
//371xxx003 is the ID of the variable group.
{
override fun completed(response: APIResponse, variableGroup: ZCRMVariableGroup)
{
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException)
{
println("Throws Exception : $exception")
}
})
//$variable1 and variable2 are the objects of ZCRMVariable
//define the variables with their values and add them to variableList
$variable1.name = "EmailID"
$variable1.value = "boyle@zylker.com"
variableList.add(variable1)
$variable2.name = "EmpNo"
$variable2.description = "The value of this variable should be unique"
variableList.add(variable2)
//Call updateVariables() by passing the variableList as a parameter to it
ZCRMSDKUtil.updateVariables(variableList, object:ResponseCallback<BulkAPIResponse>{
override fun completed(response: BulkAPIResponse) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception in updating the variable:$exception")
}
})
}
//$variable object is of ZCRMVariable
//define the value of the variable using $variable object
$variable.name == "CustID"
$variable.value == "Cx125"
//call update() using $variable object
$variable.update(object:ResponseCallback<APIResponse>
{
override fun completed(response: APIResponse) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception: $exception")
}
})
val variableList = arrayListOf<Long>()
variableList.add(371xxx003)
variableList.add(371xxx011)// 371xxx003 and 371xxx011 are the variable ids
//call deleteVariables() by passing the variableList as a parameter
ZCRMSDKUtil.deleteVariables(variableList,object : ResponseCallback<BulkAPIResponse>{
override fun completed(response: BulkAPIResponse) {
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException) {
println("Throws Exception : $exception")
}
})
//$variable object is of ZCRMVariable
//call delete() using $variable object
$variable.delete(object:ResponseCallback<APIResponse>
{
override fun completed(response: APIResponse)
{
println("${response.responseJSON}")
}
override fun failed(exception: ZCRMException)
{
println("Throws Exception: $exception")
}
})