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 / Terminate the flow whe...
Power Automate
Unanswered

Terminate the flow when other flow is go for approval

(0) ShareShare
ReportReport
Posted on by 2
I have created a Power Automate flow that sends an email directly to the approver for approval(send an email with options) whenever an item is created in the list. Additionally, I have set up another flow triggered by the 'Send Reminder' button in Power Apps, which sends an email to the approver with 'Approve' or 'Reject' action buttons. My goal is for the flow to behave in such a way that, when the second flow is triggered, the first flow is automatically canceled to prevent the approver from receiving multiple emails with action buttons. How to achieve this. 
Categories:
I have the same question (0)
  • Verified answer
    VASANTH KUMAR BALMADI Profile Picture
    266 on at

    Hi,

    To ensure that your first flow is automatically canceled when the second flow is triggered, you can implement a mechanism to manage and terminate the first flow execution dynamically. Here’s how you can achieve this:

    Step-by-Step Solution

    1. Identify the Running Instance of the First Flow

    • When the first flow is triggered, store the Run ID or an identifier in a SharePoint list, Dataverse, or any other centralized store.
    • This identifier can be used later to terminate the flow.

    Steps in the First Flow:

    1. Add an action to retrieve the unique Run ID:
      • Use the workflow() function in a Compose action to get metadata about the current flow, including the run ID.
      • Example:
        workflow()['run']['name']
    2. Save this Run ID along with a unique identifier for the list item (e.g., List Item ID) in a SharePoint list or Dataverse table.

    2. Trigger the Second Flow

    • When the "Send Reminder" button in Power Apps is clicked, trigger the second flow.

    Steps in the Second Flow:

    1. Retrieve the saved Run ID from the centralized store for the corresponding list item.
    2. Use the Terminate Flow action to cancel the first flow.

    3. Use the Terminate Flow Action

    • Power Automate doesn’t have a direct built-in action to terminate other flows, but you can achieve this using the Power Automate Management connector.

    Steps:

    1. Add the "List Runs" action from the Power Automate Management connector:
      • Filter by the specific flow name and status (e.g., "Running").
      • Use the run ID retrieved earlier to identify the exact instance.
    2. Add the "Cancel Flow Run" action from the same connector:
      • Pass the Flow Name and Run ID to terminate the running instance of the first flow.

    4. Design Logic to Prevent Overlap

    • After terminating the first flow, proceed with sending the email from the second flow.
    • Optionally, update the centralized store to mark the first flow as canceled.

    Simplified Flow Logic

    First Flow:

    1. Trigger: When an item is created.
    2. Save the current flow's Run ID in a centralized store.
    3. Proceed with sending the email for approval.

    Second Flow:

    1. Trigger: Power Apps "Send Reminder" button.
    2. Retrieve the Run ID of the first flow (if any) for the corresponding list item.
    3. Use the "Cancel Flow Run" action to terminate the first flow.
    4. Send a new approval email.

    Additional Considerations

    • Concurrency Control: Use a flag or status in your list to indicate whether the first flow is already running, and prevent it from being triggered if the second flow has already run.
    • Timeouts: Set a timeout in the first flow to avoid long-running instances.
    • Error Handling: Ensure the second flow gracefully handles cases where no active run of the first flow exists.
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

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