cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chipper
Advocate II
Advocate II

Running a script is hit and miss.

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

1 ACCEPTED SOLUTION

Accepted Solutions
Chipper
Advocate II
Advocate II

I think I have figured this one out.  The Excel step for running a script does appear to use the file ID instead of the file name.  After running into some other issues with other triggers, I learned how to use "Get file metadata using path".  This one is different than using "Get File Metadata".  The second one uses the file ID to get the info, the first one uses the path to get the info and disregards the file ID.

 

This is the steps that I used.

 

Screen Shot 2021-08-06 at 8.27.36 AM.png

 

I have run this one several times on different files and so far it works.

View solution in original post

18 REPLIES 18
automate1t
Regular Visitor

I am also running up against this issue. I have an Excel spreadsheet which comes in daily which I save to OneDrive using Power Automate. I have an Office Script which then re-formats the file and I then need to distribute that file to a number of people. The issue is that when you use Power Automate to run the script even though you choose the file the script is actually looking for a specific file ID rather than the a file with a particular name. The result is that when the new file is saved in OneDrive it gets a new ID and the script then fails. For me it seems a really big problem because you either have to manually intervene to copy the data into the existing file or run the Office Script manually. In either case the automation bit goes out the window. I cannot see any good ways to achieve the automation I desire as the options for Excel in Power Automate are quite limited.

Chipper
Advocate II
Advocate II

Was wondering if anyone else had any thougth?

AlaskanPowrUser
Frequent Visitor

also looking for a solution to this. 

AlaskanPowrUser
Frequent Visitor

Screen Shot 2021-07-11 at 3.42.39 PM.png

 

This is the script. Pretty basic. 

Chipper
Advocate II
Advocate II

I have a feeling that what we are going to have to do is create a blank worksheet. Then use power automate to populate that worksheet. Then run our script. 

Then, on the next day, clear that worksheet, and run the script again. 

AlaskanPowrUser
Frequent Visitor

I have a slight variation, But i'm running across the same error executing a script. 

I receive an .xlsx via email, and I am unable to change the fact that the data within is not in a formatted table. So I'm in a rough spot, because (to my understanding) I am unable to read excel data unless it's in a table. 

The goal here, was to use power automate to trigger on receiving an email, pull the attachment, create file using content bytes, then run a script that simply turns a consistent set of columns into a table 200 rows down always (30 should be fine, buffer) and THEN I can get rows from that newly created excel table, and start backing up the data to a sharepoint list (eventually an sql table, but sharepoint for demo purposes) 

Chipper
Advocate II
Advocate II

I think I have figured this one out.  The Excel step for running a script does appear to use the file ID instead of the file name.  After running into some other issues with other triggers, I learned how to use "Get file metadata using path".  This one is different than using "Get File Metadata".  The second one uses the file ID to get the info, the first one uses the path to get the info and disregards the file ID.

 

This is the steps that I used.

 

Screen Shot 2021-08-06 at 8.27.36 AM.png

 

I have run this one several times on different files and so far it works.

Anonymous
Not applicable

I have experienced something similar, but I think its a bug in Power Automate, I can replicate it too. 

 

I had one Run Script that just did not work, when all the other Run Script actions worked fine doing the same exact thing.  Nothing I did worked, and it wasn't logical. 

 

My solution was to delete the Run Script, add the action back in re-enter the fields, it worked after that.  The problem seems to be changing the Document it points to after the action has already been created, it will no longer read Excel Files after this.  The current solution proposed would work because they're creating a new action, and are discarding the defunct one. 

Chipper
Advocate II
Advocate II

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.

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.

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

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-singl...

 

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

zak325
New Member

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!

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

 

 

Can you post some screen shots?

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

SujithNarayanan
Frequent Visitor

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

 

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

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages