Scala SDK Samples - Custom View Operations
Get Custom views
Get a Custom View
package com.zoho.crm.sample.customview
import java.util
import com.zoho.crm.api.ParameterMap
import com.zoho.crm.api.customviews.APIException
import com.zoho.crm.api.customviews.Criteria
import com.zoho.crm.api.customviews.CustomViewsOperations
import com.zoho.crm.api.customviews.CustomViewsOperations.GetCustomViewsParam
import com.zoho.crm.api.customviews.Info
import com.zoho.crm.api.customviews.ResponseHandler
import com.zoho.crm.api.customviews.ResponseWrapper
import com.zoho.crm.api.customviews.SharedDetails
import com.zoho.crm.api.customviews.Translation
import com.zoho.crm.api.util.APIResponse
import com.zoho.crm.api.util.Model
object CustomViews {
/**
* This method is used to get the data of any specific custom view of the module.
* Specify the custom view ID of the module in your API request whose custom view data you want to retrieve.
*
* @param moduleAPIName - Specify the API name of the required module.
* @param customViewId - ID of the CustomView to be obtained.
* @throws Exception
*/
@throws[Exception]
def getCustomView(moduleAPIName: String, customViewId: Long): Unit = { //Long customViewId = 34770605629003
val customViewsOperations = new CustomViewsOperations(Option(moduleAPIName))
//Call getCustomView method that takes customViewId as parameter
val responseOption = customViewsOperations.getCustomView(customViewId)
if (responseOption.isDefined) {
val response = responseOption.get
println("Status Code: " + response.getStatusCode)
if (util.Arrays.asList(204, 304).contains(response.getStatusCode)) {
println(if (response.getStatusCode == 204) "No Content"
else "Not Modified")
return
}
if (response.isExpected) {
val responseHandler = response.getObject
if (responseHandler.isInstanceOf[ResponseWrapper]) {
val responseWrapper = responseHandler.asInstanceOf[ResponseWrapper]
val customViews = responseWrapper.getCustomViews
for (customView {
println(entry._1 + ": " + entry._2)
})
println("Message: " + exception.getMessage.getValue)
}
}
else {
val responseObject = response.getModel
val clas = responseObject.getClass
val fields = clas.getDeclaredFields
for (field