cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Power Automate - Suppress error from create table

Hi All,

 

I have this flow to import data from a spreadsheet to a SP list,

flow.png

 

The problems is that there is a varying amount of rows in the spreadsheet. The range A1:H30 is actually A1:~H1600.

I can set the range to be A1:H5000 however when the approx 1500 records are imported it tried to read the blank lines and when placing them into the shaarepoint list it errors as it is expecting a number instead of a blank record.

 

Although the flow works, it errors every time so I cannot detect real errors when this is placed live.

Does anyone know how I can stop when all the real, actual data is imported to prevent it trying to create blank records and erroring out please?

Any help would be much appreciated.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @MikeWJS 

 

You could simply list rows after the run script action, equally, you could pass back data from the script to PowerAutomate without even the need to create a table.  I don't think you need another flow here.

 

The following would return data to Power Automate in one action:

 

function main(workbook: ExcelScript.Workbook,
SheetNamestring = "Sheet1"
) {

 

  const selectedSheet = workbook.getWorksheet(SheetName);
  let data=selectedSheet.getUsedRange().getValues()
  console.log(data)
  return(data)
}
 
DamoBird365_0-1648494014379.png

 

Where I have compose2, insert a create item and for each of the values use the expression:

items('Apply_to_each')?[0]

1,2 etc...

 

If you want to skip the first row, use the following expression and insert that instead of the result.

 

skip(outputs('Run_script')?['body']?['result'],1)

 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

 

View solution in original post

6 REPLIES 6

Hi @MikeWJS 

 

A couple of options for you.  You could use office scripts to detect the used range of cells and create a table.  Something like the following script, which you can see in use here https://youtu.be/ZejstvPiFZw

 

function main(workbook: ExcelScript.Workbook,
TableName: string = "Table1",
SheetName: string = "Sheet1"
) {
// Get the worksheet by name
const selectedSheet = workbook.getWorksheet(SheetName);
// Alternatively, get the first worksheet (uncomment below and comment out above)
// const selectedSheet = workbook.getFirstWorksheet();
// Create a table using the data range.
let newTable = workbook.addTable(selectedSheet.getUsedRange(), true);
newTable.setName(TableName);
}

 

Or, once you have used your method to create a table larger than the actual data, you could run a "filter array" action on the value from the list rows, where a field is not null (assuming that all cells have data) and this would return an array of values for you to create items for.

 

Damien

Thanks for your response!

The script works fantastically well and creates a table of the actual data range in the created spreadsheet as per the video, however when I then try to import into the sharepoint list, I cannot use the table name for "get tables".

I have created a second flow which looks for new spreadsheets in the shared documents area on Sharepoint Documents to import them into the SP list however it returns the following,

capture.png

 

Could you please elaborate on how I can use a filter array action if that may work? If you look at my original flow, it uses the value not the array.

Any further help much appreciated, I am so tantalisingly close now 😞

 

Hi @MikeWJS 

 

If your flow is based on the same excel file being created, it won’t yet have a table until you run the script? You might also need to add a delay of 6 minutes, it’s a limitation of excel actions.  

https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#:~:text=An%20Excel%20file%20may%20b....


Damien

Thank you so much again for responding!

I should clarify, the flow is in two steps,

The first one is this, which works perfectly (thanks for that!)

part1.png

 

So now I have the data in sharepoint, as a spreadsheet in the document library, with a table created in it.

So far so good!

 

Now I am trying to actually import the data from the spreadsheet in the document library to the list.

I thought I could use the when a file is created in a folder to trigger the import (i.e. when the spreadsheet is created in the doc library to trigger the import but as you say, maybe it is the locks).

As earlier posted, here is the one (part 2) that fails,

 

part2.png

 

 

Basically what I want to do is at a certain time, take the contents of the spreadsheet and import them into the list but I am unsure how to reference the spreadsheet as it will be recreated each time so it will be dynamic (statics will fail).

 

Maybe some logic like get the file name in the sharepoint document library, then get the table name, then use this table name in the list rows present in spreadsheet, then use this data to "create item" in sharepoint.

 

Thanks once again for taking the time to respond, your help is very much appreciated!

 

Hi @MikeWJS 

 

You could simply list rows after the run script action, equally, you could pass back data from the script to PowerAutomate without even the need to create a table.  I don't think you need another flow here.

 

The following would return data to Power Automate in one action:

 

function main(workbook: ExcelScript.Workbook,
SheetNamestring = "Sheet1"
) {

 

  const selectedSheet = workbook.getWorksheet(SheetName);
  let data=selectedSheet.getUsedRange().getValues()
  console.log(data)
  return(data)
}
 
DamoBird365_0-1648494014379.png

 

Where I have compose2, insert a create item and for each of the values use the expression:

items('Apply_to_each')?[0]

1,2 etc...

 

If you want to skip the first row, use the following expression and insert that instead of the result.

 

skip(outputs('Run_script')?['body']?['result'],1)

 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

 

@DamoBird365 Thanks you so much for your help on this, I finally managed to get a working solution from the information you gave me.

The final solution looked like this,

 

flow.png

Where the script used was yours (above) and the create item was of the form 

items('Apply_to_each')?[x] where x was the array identifier integer.
 
I cannot stress how appreciative I am of your help, in fact, please p.m. me and I would be happy to send you a contribution to buy yourself some beers! (seriously).
Once again, thanks so much for your help!

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 in the Forums 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 of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (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. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     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 Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     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 Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

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

Users online (764)