Is there any function that can be in place of line 11?

41 Views Asked by At

I have a problem with script when trying to run flow in power automate. It was working in last week but now for some reason is not working and returning this error :

{
  "error": {
    "code": 502,
    "source": "flow-apim-msmanaged-na-westus2-01.azure-apim.net",
    "clientRequestId": "80fc1432-3104-42df-b926-6e57c5c04aa4",
    "message": "BadGateway",
    "innerError": {
      "message": "We were unable to run the script. Please try again.\nOffice JS error: Line 11: Range clear: The request failed with status code of 404.\r\nclientRequestId: 80fc1432-3104-42df-b926-6e57c5c04aa4",
      "logs": []
    }
  }
}

The code looks like this:

function main(workbook: ExcelScript.Workbook, wsName: string, startCell: string, strArr: string) {

  // Convert the strArr to an array
  let newDataArr: string[][] = JSON.parse(strArr);

  // Declare and assign the worksheet
  let ws = workbook.getWorksheet(wsName);

  // Clear the existing data in the worksheet
  let clearRange = ws.getUsedRange();
  clearRange.clear(ExcelScript.ClearApplyTo.contents);

  // Paste the new data into the worksheet
  let dataRng = ws.getRange(startCell).getAbsoluteResizedRange(newDataArr.length, newDataArr[0].length);
  dataRng.setValues(newDataArr);
}

I don't know what is the problem with this.

I would like to clear data in worksheet before pasting data

Skin asked for screenshot of worksheet

0

There are 0 best solutions below