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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate flow ru...
Power Automate
Suggested Answer

Power Automate flow runs successfully but the Office Script is not run

(1) ShareShare
ReportReport
Posted on by 15
I run the script every hour automatically via Power Automate Flow.
Office script is defined like this:
 
function main(workbook: ExcelScript.Workbook) {
    //Take the used range in the first sheet
    let range = workbook.getWorksheet("Current").getUsedRange();
    let rows = range.getRowCount();
    let values = range.getValues();
    var valuesOfRows: (number | string | boolean)[][] = []
 
    //check if any rows are more than 2 hours old
    for (var i = 0; i < rows; i++) {
        let tempdate = values[i][24];
        let twohoursold = Date.now() + -1*3600*1000;
        if (tempdate <= twohoursold)
        valuesOfRows.push(values[i]);
    }
 
    //get the used range in the second sheet
    let usedRange = workbook.getWorksheet("Archive").getUsedRange();
 
    //get the range of where the rows will be added (below the used range of the second sheet)
    let newRowRange = usedRange.getRowsBelow(valuesOfRows.length);
 
    //make sure that the new row range has the right amount of columns for the new data to be added
    let dataRange = workbook.getActiveWorksheet().getRangeByIndexes(newRowRange.getRowIndex(), newRowRange.getColumnIndex(), newRowRange.getRowCount(), valuesOfRows[0].length);
 
    //set the row data to be added in the correct range
    dataRange.setValues(valuesOfRows);
}


And the Power Automate flow is like this:



When running the script manually from excel, the script runs successfully.
However, when running it from Power Automate, it shows that it ran successfully but it doesn't actually run the script.
Is this a bug or a limitation in Power Automate?

 
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,090 Super User 2026 Season 1 on at
    Export the script to an .osts file. Then use this action and configure it as shown to call and run the script. I find this more reliable:
     
    This has more information for exporting the script to a file: Office Scripts file storage and ownership - Office Scripts | Microsoft Learn
  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at
    An office script in the service will not know what you mean by "current workbook".  Specify your target explicitly.
  • CU20032117-0 Profile Picture
    15 on at
    @lbendlin  As far as I know, you can't specify the target explicitly. Please give an example of how you'd do that.
    The function accepts a name or an ID, not the full URL/location where the workbook resides.
  • CU20032117-0 Profile Picture
    15 on at
    @David_MA, I followed the exact steps but the result is still empty. No error, the flow succeeds but no actual action is done by the script.
    Another person suggested to target the workbook specifically. Do you know how that's done?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard