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 / Getting Status Code 40...
Power Automate
Unanswered

Getting Status Code 400 error on Run Office Script step, triggered by Status Code 504 when the Office Script runs

(0) ShareShare
ReportReport
Posted on by 21

My flow stops at the step where I need to run an Office Script on a file. The error message being thrown:

 

 

 

We were unable to run the script. Please try again.\nOffice JS error: Line 7: Worksheet getRange: The request failed with status code of 504, error code UnknownError and the following error message: \r\nclientRequestId: 9de62ff1-39da-48ba-9dda-3e045296a929

 

 

 

I checked the line mentioned in the error message above and it seems to be timing out when I set the formula for cell S2?

 

 

 

 let lastRow = usedRange.getRowCount().toString();

 // Line 7: Set range S2 on selectedSheet	
 selectedSheet.getRange("S2").setFormulaLocal("=SWITCH(TRUE, T2 = \"\", \"\", COUNTIFS(T$1:T$" + lastRow + ", T2) > 1, \"More than one\", \"Only one\")");

 

 

 

Is there something I can do to remedy this? When I run the Office Script manually via Excel Web, it works without issues but when it's being called by the flow, it seems to be timing out. To add, this is a file that currently has 16k rows. I've already set the calculation to Manual prior to this step.

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 317 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 247

#3
Henil Profile Picture

Henil 117

Last 30 days Overall leaderboard