Skip to main content
Community site session details

Community site session details

Session Id : mDaQWLCJvTHD+y4lmzlDAm
Power Automate - Building Flows
Answered

Running a script is hit and miss.

Like (3) ShareShare
ReportReport
Posted on 21 May 2021 17:54:58 by 116

I have a flow that starts when I new file is created.  Turns the CSV into an excel file, saves it to a one drive folder and then runs a script to clean up the file.  All of it works, up to the part of running the script.  If I open the file in Excel Online and run the script, all is good.  But when the flow tries to run it, I get this error.

 

We were unable to run the script. Please try again.
Workbook not found.
clientRequestId: f6513d18-324b-4f26-9544-d17c6a53d539

 

This is the raw output.

{
 "statusCode": 404,
 "headers": {
 "Access-Control-Expose-Headers": "Version",
 "x-ms-workflow-name": "****************************",
 "Version": "2.5",
 "x-ms-client-request-id": "****************************",
 "x-ms-request-id": "****************************",
 "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
 "X-Content-Type-Options": "nosniff",
 "X-Frame-Options": "DENY",
 "Timing-Allow-Origin": "*",
 "x-ms-apihub-cached-response": "true",
 "Cache-Control": "no-store, no-cache",
 "Date": "Fri, 21 May 2021 14:23:44 GMT",
 "Content-Length": "165",
 "Content-Type": "application/json"
 },
 "body": {
 "message": "We were unable to run the script. Please try again.\nWorkbook not found.\r\nclientRequestId: f6513d18-324b-4f26-9544-d17c6a53d539",
 "logs": []
 }
}

 

Now, if I go back in and redrill back to the file again, all runs well

 

Screen Shot 2021-05-21 at 10.32.24 AM.png

 

{
 "statusCode": 200,
 "headers": {
 "Transfer-Encoding": "chunked",
 "Vary": "Accept-Encoding",
 "Access-Control-Expose-Headers": "Version",
 "x-ms-workflow-name": "*****************************",
 "Version": "2.5",
 "x-ms-client-request-id": "*****************************",
 "x-ms-request-id": "*****************************",
 "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
 "X-Content-Type-Options": "nosniff",
 "X-Frame-Options": "DENY",
 "Cache-Control": "no-store, no-cache",
 "Set-Cookie": "ARRAffinity=fbf12317b41409d837dc9258ca2fd506a0e78d7705046af5c2a888ad2128246d;Path=/;HttpOnly;Secure;Domain=excelonline-eus.azconn-eus.p.azurewebsites.net,ARRAffinitySameSite=fbf12317b41409d837dc9258ca2fd506a0e78d7705046af5c2a888ad2128246d;Path=/;HttpOnly;SameSite=None;Secure;Domain=excelonline-eus.azconn-eus.p.azurewebsites.net",
 "Timing-Allow-Origin": "*",
 "x-ms-apihub-cached-response": "false",
 "Date": "Fri, 21 May 2021 14:31:46 GMT",
 "Content-Type": "application/json; charset=utf-8",
 "Content-Length": "25"
 },
 "body": {
 "logs": []
 }

 

So I think it has something to do with the "File" portion of the excel part of the flow.  It is using the file ID instead of just the file name?

Any thoughts on how to get around this?

 

Thanks

Chip

  • Chipper Profile Picture
    116 on 20 Mar 2024 at 19:26:53
    Re: Running a script is hit and miss.

    Screenshot 2024-03-20 at 3.10.47 PM.pngScreenshot 2024-03-20 at 3.22.49 PM.pngScreenshot 2024-03-20 at 3.24.19 PM.png

  • SujithNarayanan Profile Picture
    6 on 20 Mar 2024 at 19:01:17
    Re: Running a script is hit and miss.

    Yes, i have given the extension in the create file and also used the ID from the "Get File Metadata using path", in the Run Script. However, I am still getting the error -  "The file format is not recognized. Please check that the selected workbook is valid." 

    SujithNarayanan_0-1710961249628.png

     

  • Chipper Profile Picture
    116 on 20 Mar 2024 at 16:21:45
    Re: Running a script is hit and miss.

    Inside the "Create File", make sure you have the extension after what ever you call it.

     

    Screenshot 2024-03-20 at 12.20.31 PM.png

  • Chipper Profile Picture
    116 on 20 Mar 2024 at 14:23:20
    Re: Running a script is hit and miss.

    Can you post some screen shots?

  • SujithNarayanan Profile Picture
    6 on 20 Mar 2024 at 11:26:04
    Re: Running a script is hit and miss.

    Hi,

     

    I am using exactly the same steps mentioned by you using "Get File Metadata using path" and then passing the ID to the Run script, but i keep getting this error "The file format is not recognized. Please check that the selected workbook is valid.".

    I have tried to open the file that was created using "Create File" just above the "Get File Metadata using path" and it is all fine. The format is correct and so is the extension. Can you please suggest what could be wrong here?

    Thanks

    Sujith

     

     

  • zak325 Profile Picture
    3 on 10 Nov 2022 at 13:36:11
    Re: Running a script is hit and miss.

    Thanks so much for this! Was having a similar issue where the Excel was being emptied then populated but at times the scripts couldn't run because I'm guessing the above file Id issue. I just added a step like you showed above and re-run it with no issues!

  • pg2020 Profile Picture
    44 on 21 Oct 2022 at 12:08:37
    Re: Running a script is hit and miss.

    Dear Chipper : YOU ARE MY HERO!! 🙂

    I've been working on this error for days.

    I am currently trying to implement the following links: (Official instructions from Microsoft ! )

    https://learn.microsoft.com/en-us/office/dev/scripts/resources/samples/convert-csv

    https://learn.microsoft.com/en-us/office/dev/scripts/resources/samples/combine-worksheets-into-single-workbook

     

    The second link describes exactly how to specify a output file in the the Excel script 2.

    In the first run, the script and the flow works.
    Not in the next round.

    My findings and please Microsoft READ THIS! :

    First, there is a major limitation of the Excel Connector:

    https://learn.microsoft.com/en-us/connectors/excelonlinebusiness/

    An Excel file may be locked for an update or delete up to 6 minutes since the last use of the connector.

     

     


    And instead of as described in Microsofts instructions to select a Destination file, I did the following:

    I start a copy process that copies an empty Excel file to the destination at the beginning of the flow.
    And later in the Excel script I take the ID of the Copy file instead of the file name. 
    So the Excel script 2 always takes the new destination xlsx file that was previously copied.

    I also have to consider the 6-minute suspension. The target file is then blocked for 6 minutes. If you want to move it or overwrite it, you have to wait 6 minutes or more.

     

    03.jpg

     

    PLEASE MICROSOFT : Think things through

  • Chipper Profile Picture
    116 on 28 Jun 2022 at 12:02:09
    Re: Running a script is hit and miss.

    Yep, for some reason, it is rather particular about those IDs.

  • toyamaza Profile Picture
    3 on 28 Jun 2022 at 09:08:55
    Re: Running a script is hit and miss.

    I had the problem and found your post. I swapped the path to the workbook with File ID. It worked beautifully!

    You saved my day!! Many thanks.

  • Chipper Profile Picture
    116 on 10 Feb 2022 at 16:28:04
    Re: Running a script is hit and miss.

    I think I am following you.  And I think I figured out the same thing as you did.  You have to use the file ID for the file section.  Otherwise if the file changes, it won't take it.  Even if the file name doesn't change, the file ID still does.

     

    Screen Shot 2022-02-10 at 11.06.12 AM.png

     

    When you start messing with tables in your excel files, it can also be a pain.

     

    Screen Shot 2022-02-10 at 11.16.45 AM.png

    Screen Shot 2022-02-10 at 11.17.43 AM.png

    But once the file changes, it doesn't work because the file ID changes. So, you add the function of ID in the field, the Table and Key Columns don't show up.

     

    Screen Shot 2022-02-10 at 11.22.26 AM.png

    Screen Shot 2022-02-10 at 11.22.52 AM.png

    You have to type in the table name and make sure the down arrow turns into an "X".

     

    Screen Shot 2022-02-10 at 11.26.30 AM.png

     

    Now when the file ID changes, the scripts will still run and the table and key column will still run also.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete