{errorSource : platform, message:'Error while processing the request', status : 500}

Hi Team,

Occasionally, we are getting the following error in SMI “{status: 500, message: ‘Error while processing the request’, errorSource : platform }” and necessary action is not done in SMI.

Thanks in advance.

Regards,
Suman C.

Hi @Suman_Chinnaraju,

Greetings!

Thank you for reaching out to the community.

Could you please share the code snippet you’re using to trigger the SMI function? That would help us in debugging further.

Thanks,
Anis

Hi @Anish,

Thanks for responding. Please find the required code snippets below.

Frontend :

    window.client.request.invoke("updateBulkCommitment", { data: mapAgent1 })
      .then(async (data) => {
        console.log("updated data", data);
        bulk_update.value = "empty";
        bulk_update.disabled = "disabled";
        inputFieldStatus.disabled = "disabled";
        inputFieldStatus.setAttribute("style", "cursor: not-allowed;");
        window.updateCommitId = [];
        filterCommitmentByStatus();
 
        $("[name='statuss']").button("reset");
        try {
          await window.client.interface.trigger("showNotify", {
            type: "success",
            message: "Task Status Updated Successfully!"
          });
          inputFieldStatus.disabled = "disabled";
 
        } catch (error) {
          handleError("err in showing notification", error);
        }
 
      }, (err) => {
        console.error(err);
        bulk_update.value = "empty";
        bulk_update.disabled = "disabled";
        inputFieldStatus.disabled = "disabled";
        inputFieldStatus.setAttribute("style", "cursor: not-allowed;");
      })
  }
}

In server.js

 updateBulkCommitment: async function (args) {
    let { data } = args;
    console.log("update bulk commitment", data);
 
    let resultCommit = [];
    try {
      for (let i = 0; i < data.length; i++) {
        let response = await updateCommitmentExec(data[i], args);
        resultCommit.push(response);
      }
      renderData(null, resultCommit);
    } catch (error) {
      renderData(error);
    }
  },
};
 
function updateCommitmentExec(datas, args) {
 
  datas.commitment_id = parseInt(datas.commitment_id, 10);
  datas.ticket_id = parseInt(datas.ticket_id, 10);
  datas.assigned_agent = parseInt(datas.assigned_agent, 10);
  let cId = datas.commitment_id.toString();
  return new Promise(async (resolve, reject) => {
    try {
      let fetchedRecord = await getAllDatas(args);
 
      let parsed = JSON.parse(fetchedRecord.response);
      let valuesArr = parsed.values;
      let flattenedArr = valuesArr.flat();
      let earr = [];
      let rowNo = flattenedArr.indexOf(cId);
      while (rowNo != -1) {
        earr.push(rowNo);
        rowNo = flattenedArr.indexOf(cId, rowNo + 1);
      }
      let inc = earr[0] + 1;
      console.log(earr.push(inc));
      let overDue;
      if (datas.overdue) {
        overDue = datas.overdue;
      } else {
        overDue = '';
      }
 
      let updatedCommits = await $request.invokeTemplate("updateCommitmentByDataFilter", {
        context: {
          "sheetId": args.iparams.spreadsheetId,
          "accessToken": await googleServiceAccountToken(args)
        },
        body: JSON.stringify({
          "valueInputOption": "RAW",
          "data": [
            {
              "dataFilter": {
 
                "a1Range": `A${earr[1]}:K${earr[1]}`
              },
              "majorDimension": "ROWS",
              "values": [
                [datas.commitment_title, datas.ticket_id, datas.commitment_id, datas.description, datas.status, datas.due_date, datas.assigned_agent, datas.created_at, datas.updated_at, datas.count, overDue]
              ]
            }
          ],
          "includeValuesInResponse": true
        })
      })
 
      resolve(updatedCommits);
    } catch (error) {
      reject(error);
    }
  })
}

request.json

   "updateCommitmentByDataFilter": {
        "schema": {
            "method": "POST",
            "host": "sheets.googleapis.com",
            "path": "/v4/spreadsheets/<%= context.sheetId %>/values:batchUpdateByDataFilter",
            "headers": {
                "Authorization": "Bearer <%= context.accessToken %>",
                "Content-Type": "application/json"
              }
        },
        "options": {
            "retryDelay": 1000,
            "isOAuth": false
        }
    },

Thanks,
Suman C.