cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LP8821
Regular Visitor

Issues running a script via Power Automate

Hi

 

I have a flow set up which triggers on a form submission. The flow contains an office script that runs on my OneDrive. 

 

I am having an issue getting the script to run 100% of the time that the form is submitted. The script will only run ~50% of the time. When it fails I get the following error message in the 'Run Script' logs.

 

"message""We were unable to run the script. Please try again.\nYour file was not saved because we could not merge your changes with changes from someone else.\r\nclientRequestId: xxxxxx",
 
I am unsure what is causing this error. When triggering the script manually via Excel online it works every time and the script works ~50% of the time when running it as part of the flow.
 
When I have been testing the flow, I have been submitting the form in fairly quick succession, but the flow is always completed prior to submitting another form.
1 ACCEPTED SOLUTION

Accepted Solutions
LP8821
Regular Visitor

I'm not sure if this has fixed the issue, or just a coincidence.

 

I added a 15s delay into the flow after the spreadsheet has been updated, but before the script is run, this seems to have fixed the issue, and I have not encountered anymore errors.

View solution in original post

3 REPLIES 3
LP8821
Regular Visitor

Edit: More information on the flow and what it does in case it's relevant.

 

The form submits information to 2 spreadsheets. 1 is a a shared spreadsheet and receives all the information from the submitted form, the other is a spreadsheet only I have access to and only receives the submitters email and submission time.

 

The office script runs on the second spreadsheet, and will compare the current and previous submissions. If the submission time is >20 mins or the submitters emails are different, the script will return a value to the workflow. Whereby if the returned value matches a condition an email will be sent. 

 

(Form submission > submission to spreadsheet 1 > submission to spreadsheet 2 > Office script > Condition > End flow)

LP8821
Regular Visitor

I'm not sure if this has fixed the issue, or just a coincidence.

 

I added a 15s delay into the flow after the spreadsheet has been updated, but before the script is run, this seems to have fixed the issue, and I have not encountered anymore errors.

Yutao
Microsoft
Microsoft

@LP8821 - Glad to hear the delay workaround fixed the issue for you.

 

As far as I know, Excel Online uses a concept called "co-authoring" when there are multiple clients (in your case, Forms being one, and Office Scripts being another) working on the same workbook. Any participating co-authoring client won't directly make changes to the master workbook but to a local workbook session and the changes will periodically be synced back to the master workbook stored on OneDrive (or SharePoint). Later the changes will be propagated to other co-authoring clients of the same workbook so they can see these changes.

 

In your case, I guess there might be a timing issue. It appears when Office Script kicks in, the changes made by the Form submission hasn't been synced to the master workbook yet. So adding some delays could help.

 

BTW, since the "Get response details" action of the Forms connector can reliably retrieve the data of the current form submission that triggers the flow, I'm wondering if you would be able to directly use that data to compare with the previous data in the workbook. Just something for you to consider...

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,475)