Scala SDK Samples - Related List Operations

Get All Related Lists of a Module
              
              
package com.zoho.crm.sample.relatedlist

import java.util
import com.zoho.crm.api.relatedlists.APIException
import com.zoho.crm.api.relatedlists.RelatedListsOperations
import com.zoho.crm.api.relatedlists.ResponseHandler
import com.zoho.crm.api.relatedlists.ResponseWrapper
import com.zoho.crm.api.util.APIResponse
import com.zoho.crm.api.util.Model


object RelatedLists {
  /**
   *  Get RelatedLists 
   * This method is used to get the related list data of a particular module and print the response.
   *
   * @param moduleAPIName - The API Name of the module to get related lists
   * @throws Exception
   */
  @throws[Exception]
  def getRelatedLists(moduleAPIName: String): Unit = { //example
    //String moduleAPIName = "Leads"
    //Get instance of RelatedListsOperations Class that takes moduleAPIName as parameter
    val relatedListsOperations = new RelatedListsOperations(Option(moduleAPIName))
    //Call getRelatedLists method
    val responseOption = relatedListsOperations.getRelatedLists
    if (responseOption.isDefined) { //check response
      var 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
      }
      //Check if expected response is received
      if (response.isExpected) { //Get object from response
        val responseHandler = response.getObject
        if (responseHandler.isInstanceOf[ResponseWrapper]) { //Get the received ResponseWrapper instance
          val responseWrapper = responseHandler.asInstanceOf[ResponseWrapper]
          //Get the list of obtained RelatedList instances
          val relatedLists = responseWrapper.getRelatedLists
          for (relatedList {
              println(entry._1 + ": " + entry._2)
            })
            //Get the Message
            println("Message: " + exception.getMessage.getValue)
          }
        }
      }
      else { //If response is not as expected
        //Get model object from response
        val responseObject = response.getModel
        //Get the response object's class
        val clas = responseObject.getClass
        //Get all declared fields of the response class
        val fields = clas.getDeclaredFields
        for (field 
Get a Related List
              
              
package com.zoho.crm.sample.relatedlist

import java.util
import com.zoho.crm.api.relatedlists.APIException
import com.zoho.crm.api.relatedlists.RelatedListsOperations
import com.zoho.crm.api.relatedlists.ResponseHandler
import com.zoho.crm.api.relatedlists.ResponseWrapper
import com.zoho.crm.api.util.APIResponse
import com.zoho.crm.api.util.Model


object RelatedLists {
  /**
   *  Get RelatedList 
   * This method is used to get the single related list data of a particular module with relatedListId and print the response.
   *
   * @param moduleAPIName - The API Name of the module to get related list
   * @param relatedListId - The ID of the relatedList to be obtained
   * @throws Exception
   */
  @throws[Exception]
  def getRelatedList(moduleAPIName: String, relatedListId: Long): Unit = { //example,
    //Long relatedListId = 525508000005067912l
    val relatedListsOperations = new RelatedListsOperations(Option(moduleAPIName))
    //Call getRelatedList method which takes relatedListId as parameter
    val responseOption = relatedListsOperations.getRelatedList(relatedListId)
    if (responseOption.isDefined) { //check response
      var 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]
          //Get the list of obtained CustomView instances
          val relatedLists = responseWrapper.getRelatedLists
          for (relatedList {
            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