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 / How to return to main ...
Power Automate
Answered

How to return to main flow after subflow ends - is that possible?

(0) ShareShare
ReportReport
Posted on by

Hello Everyone.

 

I have a main flow.  When there is an error in it it runs a subflow.

 

How can I make it so that when that subflow ends it returns back to the main flow and runs the main flow from the beginning?  So, they basically loop?

 

I can't seem to find a way to make this possible.

 

Regards.

  • VJR Profile Picture
    7,635 on at

    Hi @ianwuk 

    Make use of the Labels.

    Add a Label called something like 'StartofFlow' at the beginning of your main flow.

    Then after the subflow finishes it goes to the next statement from where the subflow was called in the main flow. There add an action called 'Go to label - StartofFlow'.

    Take care of any infinite loops.

  • CU-19081228-9 Profile Picture
    on at

    @VJR 

    Thank you for replying.

    I tried that.  I have a label at the start of my main flow, then, in the subflow I use Go To and try to select the label, but there are no labels to choose from (it's empty - no labels available).

    Obviously, I am doing something wrong here.

     

    Thanks.

  • VJR Profile Picture
    7,635 on at

    Hi @ianwuk 

    That is because variables in PAD are global in nature (available everywhere) but Labels are not. They are available only on the page where they are declared.

    Therefore I have mentioned you to add in the next statement on the main flow just after you call the subflow.

     

    Then after the subflow finishes it goes to the next statement from where the subflow was called in the main flow.

    There add an action called 'Go to label - StartofFlow'.

     

    It will work fine.

  • CU-19081228-9 Profile Picture
    on at

    @VJR 

    I think I get it.

    So, my main flow is wrapped in an On Block Error segment, that, on error at any point during the flow, runs a subflow called ActiononError which just closes the current browser and waits 2 minutes.

    Because my main flow may generate an error at any step, does that mean after every step I have to add the same go to in my main flow to redirect it back to the starting label? 

    It seems like it, but surely then my main flow will never finish?

     

    Thanks.

  • CU-19081228-9 Profile Picture
    on at

    @VJR 

    Update, I changed the On block error to create a variable if there is an error, it is called HasError.

    At the start of this block, I added this:

    IF HasError = True then run subflow.

    ELSEIF HasError = False then go to label MainFlowStart.

    Based on your kind knowledge, that means that if the variable is TRUE, the sub-flow runs, and when it finishes it goes back to where it was triggered (which is the start of the On block error and the IF / ELSEIF statements above, it then is FALSE and should go to the label to start the main flow.

    Does that make sense?

  • Verified answer
    VJR Profile Picture
    7,635 on at

    Now that I better understand your scenario you can have a structure like this.

     

    Line no 5 will generate an error:

     

    VJR_0-1672976726018.png

     

    On block error:

     

    VJR_1-1672976790650.png

    SubFlow contains a sample message box.

     

    VJR_2-1672976873593.png

     

    - Ran it and worked fine

    - Test it and let me know how it goes for your situation

    - Only if there is an error, the line no. 8 will run the subflow and line no 9 will take you to the first line of the main flow.

  • CU-19081228-9 Profile Picture
    on at

    Thank you so much @VJR - I think what you have done makes sense to me.  I'll give it a try.

     

    Your help is really appreciated, not sure if you can help with my other thread at all to extract Teams message attachment and work on that data, can you?

    Re: How to read text from a Teams message posted v... - Power Platform Community (microsoft.com)

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    Why do it like that?
    Theres is no need to use the label.
    Just put the "On Block error" Around the whole code, and let the "On block Error" call the subflow.

    Highboy_0-1672994468671.png

    I know it's in Danish but I am sure you can see what I am trying to say.
    When the "block" fails, it calls the subflow "Arrrgh_Error" and then goes to start of the block.

  • Gidi Profile Picture
    601 on at

    Hi,

    thought about this solution too. Here we also need an exit strategy to avoid an endless loop (e.g. a counter at the beginning of the block that will be checked before continue with the main steps). The “On Error Block” doesn’t have a retry counter on board. 

  • CU-19081228-9 Profile Picture
    on at

    @Gidi Not sure if MS will improve this feature or not.  We just have to wait and see.

    @Highboy That was how I had it set up originally.  I didn't know that when a subflow ends it goes to the next step after where it failed.  So, in my case, with your approach, the flow would fail, run the subflow, go back to the next step of the main flow and be able to do nothing.

    Therefore, at least to me, the solution by @VJR  seems to make more sense because, if, on error (wrapped around the main On Block Error, it then drops through to the end of the On Error block (meaning no chance to carry on and fail), and runs the sub flow to start again.  Basically, avoiding getting stuck.

    Again, this is my limited knowledge here.  Thanks!

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
Mohsin Ali Profile Picture

Mohsin Ali 425

#2
11manish Profile Picture

11manish 323 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard