web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Run Script and Add Row...
Power Automate
Unanswered

Run Script and Add Row to Excel Table in the same flow

(0) ShareShare
ReportReport
Posted on by 11

Hi,

 

I've created a flow which does the following : 

 

In an Excel Template (Credit Note), it performs a run script to complete some header and footer data in the template, I then run an Add Rows to Excel Table to generate the line detail in the template. The file is then saved out to another file using the appropriate sharepoint commands (File Content, Create File etc) and then I remove the data by passing nulls through in the same run script command and delete the line detail from the excel table using delete rows, so that I have an empty template file for the next time this process is run.

 

The problems I have :

 

The flow runs, it performs the Run Script command and creates the header and footer data correctly, however, it does not generate the line data in the table when the Add Rows to Table command runs (it runs with a successful outcome according to the run progress), the second iteration of Run Script runs with a successful outcome but only passes nulls into the cells before the data table, the remove data from excel data process fails because of the blank row in the table.

 

Has anyone successfully used both Run Script and Add Row to Table in the same flow, or do I need to run 2 separate flows to do this and call the second flow from the first one (and probably a third and fourth to remove the data?). Does anyone know why blank line is persistent in the Excel table, which then causes the issue with the removal process?

 

Sorry for the long-winded post, thanks for persevering!!

Categories:
I have the same question (0)
  • Verified answer
    Unknown geen idee Profile Picture
    1,757 on at

    Dear robsims99,

    Not sure if my suggestion could help you, but it seems to me you are trying to find a solution for filling an excel template and saving a copy (and then cleaning the template), something I have done before a while back.

     

    You can actually create a new excel file (based on template) on-the-fly and in the same flow add rows to this new file. Please have a look at the example flow below and the youtube link.

     

    Again, hope this is helpful, if so, please indicate in the thread.

    Happy flowing,

    Koen

     

    https://www.youtube.com/watch?v=RB_ySjhm9Sg

     

    Koen5_0-1665410243332.png

     

     

     

  • Yutao Huang Profile Picture
    Microsoft Employee on at

    Hello @robsims99 ,

     

    I have a feeling this might be a timing issue between the "Run script" action and the "Add table row" action. I'm wondering if it'd be worth trying to add some delays (say 30 seconds) between the them. I recall seeing similar issues involving both actions in the same flow before, and adding delays would help in most cases.

     

    Another option, as @Koen5 pointed out, is to use only one type of such actions (if possible) in the same flow to avoid the potential conflict and timing issues. You can try using just the Add table row action as Koen5 suggested, or you can also try using only the Run script action to do all the work (creating header/footer and adding rows). For the Run script approach, you can even have multiple Run script actions to run different scripts if needed and there should be no timing issue.

  • robsims99 Profile Picture
    11 on at

    Thanks for this Koen5, I will give it a go, I prefer the idea of creating a file on the fly rather than doing 2 passes.

     

    Cheers,

     

    Rob.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard