Can you use office script code to start a power automate flow?

Zachary Wargo 1 Reputation point
2022-09-15T17:03:30.06+00:00

I am doing a project where excel on sharepoint is updated when a user fills out a form on a random website, I've been messing with power automate for a while but can't seem to get the trigger to call the function when the excel file is updated after a user fills in the form and instead just keeps running the flow every 3 minutes. Thus I've come to the conclusion to try and have the excel file on sharepoint use office script to recognize when a user puts in a value into excel to launch the power automate flow. Is this possible and how would one go about doing this?

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,869 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michelle Ran 341 Reputation points Microsoft Employee
    2022-09-21T20:32:00.957+00:00

    Hi Zachary, thanks for your question! It sounds like there are a few parts here, so I'll try to answer them separately:

    1. Can you use an Office Script to start a Flow? You can use the "Run script" connector as part of a Flow, but you cannot start a Flow directly from an Office Script's code.
    2. Can an Office Script recognize when a user updates a value in Excel? At this time, we don't support this.
    3. Can you start a Flow when an Excel workbook is updated? We also don't support this at the moment, but we're working on it!

    In the meantime, I'd suggest one of the following workarounds:

    1. Have your users fill out a Microsoft Form and use the "When a new response is submitted" trigger to start your Flow.
    2. Write an Office Script that checks if the Excel file has changed. For example, if you want your Flow to run when new responses are submitted through your form, you can have the script count how many responses are in the sheet and check against the last count (saved in a different part of the sheet). If there are new responses, it will update the count and return the information that the next step of your Flow needs. You would schedule this Office Script to run on a regular interval (e.g., every day), and if the script returns that new responses have been submitted, you can run the next steps of your Flow; otherwise, do nothing.

    Let me know if you have any questions about implementing one of these workarounds! I understand #2 is somewhat complex so I'm happy to go into more detail if needed.

    Best,
    Michelle

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.