Run Script (excel) in Power automate

AT_M 11 Reputation points
2021-02-15T02:56:43.65+00:00

Hi,

I created the sort script in excel online and connected to Power automate. It's set up with 'Recurrence' to run daily.
When I tested it as solo, it worked but it's failed when it's run by power automate. The error message was;
--- Quote ---
We were unable to run the script. Please try again.
Workbook not found.
clientRequestId: 0a43a19b-0b2c-4cfc-8ef9-3954a5767e0e
--- Unquote ---

I used workboog.getactiveworksheet method which is default behaviour in powerautomate.
Please advise 1) what is wrong about it and 2) is there any workaround this? Also, is there any method in script to clear table? Because, the table will be overlapped if I don't clear the table.

Look forward to hearing any idea on this.

Microsoft 365 and Office | Development | Office JavaScript API
{count} votes

6 answers

Sort by: Most helpful
  1. Yutao Huang - MSFT 701 Reputation points Microsoft Employee
    2021-03-10T23:59:19.887+00:00

    Hi @AT_M ,

    Apologize for the late response and sorry to hear your flow didn't work. Were you able to make your script work with Power Automate later?

    Regarding clearing a table, did you mean to remove the table all together? You can probably try something like workbook.getTable("Table1").delete().

    Hope this helps. Please let us know if you have any further questions.

    Thanks!
    Yutao

    0 comments No comments

  2. Nauzad Tantra 1 Reputation point
    2021-04-30T02:21:09.727+00:00

    Hi,
    Im having the same error. The script runs correctly in Excel, but does not like being called from Power Automate.

    0 comments No comments

  3. Nauzad Tantra 1 Reputation point
    2021-04-30T02:33:48.597+00:00

    @Yutao Huang - MSFT , any luck finding a solution to this issue?


  4. Clenny, Natasha 1 Reputation point
    2022-02-11T21:23:18.857+00:00

    I'm having the same issue where I'm trying to run my script through Power Automate but says

    {
    "message": "We were unable to run the script. Please try again.\nWorkbook not found.\r\nclientRequestId: 8e991480-2de9-4264-83d5-3e543acf2a0c",
    "logs": []
    }

    I've tried using getWorksheet instead of getActiveWorksheet.


  5. Bebop 1 Reputation point
    2022-03-08T22:51:07.727+00:00

    Hi,

    I have the exact same issue as @AT_M - my script runs perfectly fine on a test flow using a manual trigger but gives the following error when ran with a recurrence trigger:

    {  
      "message": "We were unable to run the script. Please try again.\nRuntime error: Line 10: Cannot read property 'match' of undefined\r\nclientRequestId: ac406dc6-b786-41b8-ae16-2ce6493b5c32",  
      "logs": []  
    }  
    

    I do not understand the error message as the match property works fine when testing with a manual flow. It clearly is something that has to do with the trigger @Yutao Huang - MSFT

    Thanks


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.