Hi,
I have a fairly long flow with 2 critical elements:1
1) Create woksheet (adds worksheet to an Excel file) - works
2) Run a script - inserts a file into the sheet create above - works, but only if I create the worksheet manually before running the flow
1 and 2 each work on their own. However I am unable to get the script to run on a worksheet created by the flow. The error I get implies that the worksheet doesn't exist:
"message": "We were unable to run the script. Please try again.\nRuntime error: Line 4: Cannot read properties of undefined (reading 'addImage')\r\nclientRequestId: 00b51c59-0d6f-4c33-a35c-4b2364a82f71",
"logs": []
Here is the full script:
function main(workbook: ExcelScript.Workbook, sheetName: string, address: string, base64ImageString: string) {
let sheet = workbook.getWorksheet(sheetName);
let range = sheet.getRange(address);
let image = sheet.addImage(base64ImageString);
image.setTop(range.getTop());
image.setLeft(range.getLeft());
}
Here is the contents of the flow:

The sheet name is the word "Image" with a counter. So the sheet names are Image1, Image2, Image 3, etc.