Cancel a Flow from PowerApps?

%3CLINGO-SUB%20id%3D%22lingo-sub-228941%22%20slang%3D%22en-US%22%3ECancel%20a%20Flow%20from%20PowerApps%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-228941%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20World!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20currently%20trying%20to%20sync%20an%20approval%20Flow%20with%20a%20PowerApps%20Leave%20Request%20demo.%20I%20have%20modified%20the%20PowerApp%20to%20start%20a%20flow%20when%20a%20new%20request%20is%20created%20(in%20the%20OnSelect%20property%20just%20after%20the%20request%20is%20saved%20to%20SharePoint.)%20%3CSPAN%3EIf%20a%20request%20is%20approved%2Fdeclined%20via%20Flow%2C%20everything%20is%20fine%20as%20my%20app%20can%20detect%20that%20the%20status%20is%20no%20longer%20%22Pending%22%20and%20the%20%22Approve%22%20and%20%22Reject%22%20buttons%20in%20the%20email%20are%20gone.%20%3C%2FSPAN%3EThis%20all%20works%20fine%2C%20but%20a%20problem%20arises%20when%20a%20manager%20approves%2Fdeclines%20in%20app.%20If%20a%20request%20is%20approved%2Fdeclined%20in%20app%2C%20the%20email%20with%20the%20approval%20still%20has%20the%20%22Approve%22%20and%20%22Reject%22%20buttons%2C%20meaning%20they%20could%20reject%20a%20request%20that%20has%20already%20been%20approved.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20that%20I%20could%26nbsp%3Bcancel%20a%20flow%20from%20PowerApps%20(maybe%20using%20an%20id%20for%20the%20flow%20saved%20to%20a%20column%20in%20SharePoint%3F)%20so%20that%20once%20a%20request%20is%26nbsp%3B%3CSPAN%3Eapproved%2Fdeclined%3C%2FSPAN%3E%20in%20either%20place%2C%20all%20buttons%20will%20do%20nothing%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EJordan%20Holleman%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-228941%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-229410%22%20slang%3D%22en-US%22%3ERe%3A%20Cancel%20a%20Flow%20from%20PowerApps%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-229410%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20not%20fully%20tested%20it%20but%20a%20variation%20on%20the%20following%20flow%20might%20work.%26nbsp%3B%20It%20initializes%20a%20variable%20as%20false%2C%20then%20will%20set%20the%20variable%20as%20true%20once%20the%20approval%20happens.%26nbsp%3B%20If%20you%20create%20a%20parallel%20branch%20that%20has%20a%20%22do%20until%22%20the%20variable%20is%20set%20to%20true.%26nbsp%3B%20That%20%22do%20until%22%20will%20check%20to%20see%20if%20the%20status%20has%20changed%20from%20pending%20and%20if%20it%20has%2C%20then%20it%20will%20terminate%20the%20flow.%20%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F39803i9D9EF7C958AB0DB9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22flow.PNG%22%20title%3D%22flow.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-229173%22%20slang%3D%22en-US%22%3ERe%3A%20Cancel%20a%20Flow%20from%20PowerApps%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-229173%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20sounds%20like%20conditions%20in%20flow.%20so%20you%20will%20have%20to%20check%20the%20value%20of%20your%20column%2Finput%20and%20use%20a%20if%20statement%20in%20flow%20to%20correctly%20follow%20your%20flow%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1606663%22%20slang%3D%22en-US%22%3ERe%3A%20Cancel%20a%20Flow%20from%20PowerApps%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1606663%22%20slang%3D%22en-US%22%3E%3CP%3EI%20tried%20this%20one%20but%20it%20says%20I%20cannot%20put%20Terminate%20control%20in%20Do%20until%20loop%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hello World!

 

I am currently trying to sync an approval Flow with a PowerApps Leave Request demo. I have modified the PowerApp to start a flow when a new request is created (in the OnSelect property just after the request is saved to SharePoint.) If a request is approved/declined via Flow, everything is fine as my app can detect that the status is no longer "Pending" and the "Approve" and "Reject" buttons in the email are gone. This all works fine, but a problem arises when a manager approves/declines in app. If a request is approved/declined in app, the email with the approval still has the "Approve" and "Reject" buttons, meaning they could reject a request that has already been approved.

 

Is there a way that I could cancel a flow from PowerApps (maybe using an id for the flow saved to a column in SharePoint?) so that once a request is approved/declined in either place, all buttons will do nothing?

 

Thanks,

Jordan Holleman

3 Replies

This sounds like conditions in flow. so you will have to check the value of your column/input and use a if statement in flow to correctly follow your flow

I have not fully tested it but a variation on the following flow might work.  It initializes a variable as false, then will set the variable as true once the approval happens.  If you create a parallel branch that has a "do until" the variable is set to true.  That "do until" will check to see if the status has changed from pending and if it has, then it will terminate the flow.  

flow.PNG

I tried this one but it says I cannot put Terminate control in Do until loop