Get the deleted record data from zoho crm and update the change in NetSuite accordingly.

to fetch the deleted data,we can use Request URL:

https://www.zohoapis.com/crm/v2/{module_api_name}/deleted

/**

      * Defines the function that fetches deleted Zoho data.

      * @param {Object} customRecord – The custom record containing Zoho last run information

      * @param {string} accessToken – The access token to authenticate with Zoho API

      * @param {string} lastRunTime – The last run time for Zoho data retrieval

      * @returns {Array} An array of deleted Zoho record IDs

      */

    function fetchDeletedData(customRecord, accessToken) {

      let idsArray = [];

      let lastRunTime = generateLastRunDate()

      let headerObj = {

        Authorization: “Zoho-oauthtoken ” + accessToken,

        “If-Modified-Since”: lastRunTime

      };

      try {

        let oppoDeleteResponse = https.get({

          url: “https://www.zohoapis.in/crm/v2/Deals/deleted”,

          headers: headerObj,

        });

        if (oppoDeleteResponse.code === 200) {

          let deleteResponseBody = oppoDeleteResponse.body;

          deleteResponseBody = JSON.parse(deleteResponseBody);

          let delDataArray = deleteResponseBody.data;

          idsArray = delDataArray.map(item => item.id);

        }

        return idsArray;

      } catch (e) {

        log.error({ title: “Error in fetchDeletedData”, details: e });

        return [];

      }

    }

Leave a comment

Your email address will not be published. Required fields are marked *