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")
}
})
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")
}
})
//new variable groups
val varGroup1 = ZCRMSDKUtil.newVariableGroup("Customer Reference")
val varGroup2 = ZCRMSDKUtil.newVariableGroup("Connection Detail")
//define new variables
//Call newVariable() by passing the name, apiName and VariableType as parameters to it.
//name - display name of the variable that you want to create.
//apiName - name with which the variable is to be referred in any API request.
//VariableType - data type of the variable (TEXT, CURRENCY, DATE, DATETIME, DOUBLE, EMAIL, LONG, TEXTAREA, INTEGER, PERCENT, PHONE, WEBSITE, CHECKBOX).
val newVariable1 = ZCRMSDKUtil.newVariable("Reference No.","Reference",CommonUtil.VariableType.INTEGER,varGroup1)
val newVariable2 = ZCRMSDKUtil.newVariable("Connection ID","Internet",CommonUtil.VariableType.INTEGER,varGroup2)
//add the defined variables to the list variableList
val variableList = arrayListOf<ZCRMVariable>()
variableList.add(newVariable1)
variableList.add(newVariable2)
//call createVariables() to create new variables as defined above.
//pass the variableList as parameter to the createVariables()
ZCRMSDKUtil.createVariables(variableList,object:DataCallback<BulkAPIResponse,List<ZCRMVariable>>
{
override fun completed(response: BulkAPIResponse, zcrmvariables: List<ZCRMVariable>)
{
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")
}
})