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.

berandomsen
Frequent Visitor

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.

pg2020
Helper I
Helper I

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
Regular 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

Exclusive LIVE Community Event: Power Apps Copilot Coffee Chat with Copilot Studio Product Team

It's time for the SECOND Power Apps Copilot Coffee Chat featuring the Copilot Studio product team, which will be held LIVE on April 3, 2024 at 9:30 AM Pacific Daylight Time (PDT).     This is an incredible opportunity to connect with members of the Copilot Studio product team and ask them anything about Copilot Studio. We'll share our special guests with you shortly--but we want to encourage to mark your calendars now because you will not want to miss the conversation.   This live event will give you the unique opportunity to learn more about Copilot Studio plans, where we’ll focus, and get insight into upcoming features. We’re looking forward to hearing from the community, so bring your questions!   TO GET ACCESS TO THIS EXCLUSIVE AMA: Kudo this post to reserve your spot! Reserve your spot now by kudoing this post.  Reservations will be prioritized on when your kudo for the post comes through, so don't wait! Click that "kudo button" today.   Invitations will be sent on April 2nd.Users posting Kudos after April 2nd at 9AM PDT may not receive an invitation but will be able to view the session online after conclusion of the event. Give your "kudo" today and mark your calendars for April 3, 2024 at 9:30 AM PDT and join us for an engaging and informative session!

Tuesday Tip: Unlocking Community Achievements and Earning Badges

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!     THIS WEEK'S TIP: Unlocking Achievements and Earning BadgesAcross the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. These badges each signify a different achievement--and all of those achievements are available to any Community member! If you're a seasoned pro or just getting started, you too can earn badges for the great work you do. Check out some details on Community badges below--and find out more in the detailed link at the end of the article!       A Diverse Range of Badges to Collect The badges you can earn in the Community cover a wide array of activities, including: Kudos Received: Acknowledges the number of times a user’s post has been appreciated with a “Kudo.”Kudos Given: Highlights the user’s generosity in recognizing others’ contributions.Topics Created: Tracks the number of discussions initiated by a user.Solutions Provided: Celebrates the instances where a user’s response is marked as the correct solution.Reply: Counts the number of times a user has engaged with community discussions.Blog Contributor: Honors those who contribute valuable content and are invited to write for the community blog.       A Community Evolving Together Badges are not only a great way to recognize outstanding contributions of our amazing Community members--they are also a way to continue fostering a collaborative and supportive environment. As you continue to share your knowledge and assist each other these badges serve as a visual representation of your valuable contributions.   Find out more about badges in these Community Support pages in each Community: All About Community Badges - Power Apps CommunityAll About Community Badges - Power Automate CommunityAll About Community Badges - Copilot Studio CommunityAll About Community Badges - Power Pages Community

Tuesday Tips: Powering Up Your Community Profile

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week's Tip: Power Up Your Profile!  🚀 It's where every Community member gets their start, and it's essential that you keep it updated! Your Community User Profile is how you're able to get messages, post solutions, ask questions--and as you rank up, it's where your badges will appear and how you'll be known when you start blogging in the Community Blog. Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile.     Password Puzzles? No Problem! Find out how to sync your Azure AD password with your community account, ensuring a seamless sign-in. No separate passwords to remember! Job Jumps & Email Swaps Changed jobs? Got a new email? Fear not! You'll find out how to link your shiny new email to your existing community account, keeping your contributions and connections intact. Username Uncertainties Unraveled Picking the perfect username is crucial--and sometimes the original choice you signed up with doesn't fit as well as you may have thought. There's a quick way to request an update here--but remember, your username is your community identity, so choose wisely. "Need Admin Approval" Warning Window? If you see this error message while using the community, don't worry. A simple process will help you get where you need to go. If you still need assistance, find out how to contact your Community Support team. Whatever you're looking for, when it comes to your profile, the Community Account Support Knowledge Base article is your treasure trove of tips as you navigate the nuances of your Community Profile. It’s the ultimate resource for keeping your digital identity in tip-top shape while engaging with the Power Platform Community. So, dive in and power up your profile today!  💪🚀   Community Account Support | Power Apps Community Account Support | Power AutomateCommunity Account Support | Copilot Studio  Community Account Support | Power Pages

Super User of the Month | Chris Piasecki

In our 2nd installment of this new ongoing feature in the Community, we're thrilled to announce that Chris Piasecki is our Super User of the Month for March 2024. If you've been in the Community for a while, we're sure you've seen a comment or marked one of Chris' helpful tips as a solution--he's been a Super User for SEVEN consecutive seasons!   Since authoring his first reply in April 2020 to his most recent achievement organizing the Canadian Power Platform Summit this month, Chris has helped countless Community members with his insights and expertise. In addition to being a Super User, Chris is also a User Group leader, Microsoft MVP, and a featured speaker at the Microsoft Power Platform Conference. His contributions to the new SUIT program, along with his joyous personality and willingness to jump in and help so many members has made Chris a fixture in the Power Platform Community.   When Chris isn't authoring solutions or organizing events, he's actively leading Piasecki Consulting, specializing in solution architecture, integration, DevOps, and more--helping clients discover how to strategize and implement Microsoft's technology platforms. We are grateful for Chris' insightful help in the Community and look forward to even more amazing milestones as he continues to assist so many with his great tips, solutions--always with a smile and a great sense of humor.You can find Chris in the Community and on LinkedIn. Thanks for being such a SUPER user, Chris! 💪 🌠  

Tuesday Tips: Community Ranks and YOU

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!This Week: Community Ranks--Moving from "Member" to "Community Champion"   Have you ever wondered how your fellow community members ascend the ranks within our community? What sets apart an Advocate from a Helper, or a Solution Sage from a Community Champion? In today’s #TuesdayTip, we’re unveiling the secrets and sharing tips to help YOU elevate your ranking—and why it matters to our vibrant communities. Community ranks serve as a window into a member’s role and activity. They celebrate your accomplishments and reveal whether someone has been actively contributing and assisting others. For instance, a Super User is someone who has been exceptionally helpful and engaged. Some ranks even come with special permissions, especially those related to community management. As you actively participate—whether by creating new topics, providing solutions, or earning kudos—your rank can climb. Each time you achieve a new rank, you’ll receive an email notification. Look out for the icon and rank name displayed next to your username—it’s a badge of honor! Fun fact: Your Community Engagement Team keeps an eye on these ranks, recognizing the most passionate and active community members. So shine brightly with valuable content, and you might just earn well-deserved recognition! Where can you see someone’s rank? When viewing a post, you’ll find a member’s rank to the left of their name.Click on a username to explore their profile, where their rank is prominently displayed. What about the ranks themselves? New members start as New Members, progressing to Regular Visitors, and then Frequent Visitors.Beyond that, we have a categorized system: Kudo Ranks: Earned through kudos (teal icons).Post Ranks: Based on your posts (purple icons).Solution Ranks: Reflecting your solutions (green icons).Combo Ranks: These orange icons combine kudos, solutions, and posts. The top ranks have unique names, making your journey even more exciting! So dive in, collect those kudos, share solutions, and let’s see how high you can rank!  🌟 🚀   Check out the Using the Community boards in each of the communities for more helpful information!  Power Apps, Power Automate, Copilot Studio & Power Pages

Find Out What Makes Super Users So Super

We know many of you visit the Power Platform Communities to ask questions and receive answers. But do you know that many of our best answers and solutions come from Community members who are super active, helping anyone who needs a little help getting unstuck with Business Applications products? We call these dedicated Community members Super Users because they are the real heroes in the Community, willing to jump in whenever they can to help! Maybe you've encountered them yourself and they've solved some of your biggest questions. Have you ever wondered, "Why?"We interviewed several of our Super Users to understand what drives them to help in the Community--and discover the difference it has made in their lives as well! Take a look in our gallery today: What Motivates a Super User? - Power Platform Community (microsoft.com)

Users online (4,685)