You need to sign in to do that
Don't have an account?

Controlling Finish actions outside of a VFP
Is there a way to change the Finish button default on a VWF run from a custom button URL that's not referencing a VFP? Basically I have a simple flow that starts with a button click from a detail page, which opens a new browser window and shows some data along with the standard VWF Finish button.
What I'd like is for finish to close the window, not restart the workflow.
You could pass in a return URL (e.g retURL=URLFOR({!Lead.Id})), so that when the flow finishes in the new window it is redirected back to the detail page of your record, but this wont close the new window.
Salesforce recommend against this if you are using a link that opens the flow in the existing window because you will end up with a salesforce page with side bar and top panel within a salesforce window with side bar and top panel etc.
The other option is to create a visualforce page to display your flow. You could then have some javascript / jquery that 'rehooks' the Finish button event so that it closes the window. There is a finishLocation parameter that will redirect the page but it wont close the window.
I'm just starting with flows - they seem like pretty powerful tools for managing data quality and doing process checks. However, the finish behavior just baffles me - it seems intuitive that when you click "Finish", the window should close, or at least that there should be some (easy) way to configure this in the designer. What am I missing about the original intent for flows that Salesforce had? What is the use-case where you'd want to restart the flow from the beginning? (not to mention having lost the record context at that point). I don't get it.
We run our flows off a button on a detail page, as per the original post. We want the user to click the button, have the flow pop-up and guide them through a process, then they click "Finish" at the end and the pop-up flow closes and they're returned to the originating page. Might someone be able to provide a little more detail on how to effect this? Many thanks. -Ben
I am with Benjobobby here in seeking a clean close method. I'll have to log something to Ideas if I can't find any leads for my newbiness.
This is a little weird, however the method devised kind of makes sense. What you have to do is make a VisualForce page wrapper and call that wrapper (instead of the flow) when making a button.
Sounds confusing, but it's one line line of code.
Go to Develop -> Pages -> New
And create a new VisualForce page with following content:
And of course "YourFlowName" above is the Unique Name of the flow (located on top right corner of the flow edit page). Set the finish location to wherever you like.
After that go to your object page and create a button that points to the URL of the VisualForce page.
One fun thing that isn't immediately obvious is that you can pass variables from your object to the flow by using the flow name variable in the URL string. Make sure the flow name variable isn't set to private and use the variable name in the button link URL like this:
Where "VFPage" is the name of the Visual Force page and "OppID" is the name of my flow variable. You can pass multiple variables with "&"
thanks for the VF example.
But I have a twist on the question, how do I do both?
In other words, I am using a button on the oppy page, to pass variables in from the record and set the variable for the record that I want to update. But I also want to execute this VF example, so it closes the popup when the user hits the Finish button (it will also update the records that they've filled in during the Flow).
I can't seem to figure out how to implement both solutions at the same time, since the button only allows me to select URL or VF.
Closing when done.
I don't remember if I found this somewhere or figured it out, because it's not in the documentation - but it works great. One method to close the flow page when "finish" is clicked is to first create a separate VisualForce page called "closeWin" that does just that (using Javascipt) as so:
Then set that page as the "finish location" in the flow wrapper page (mentioned in earlier post above), like this:
As soon as the user clicks finish, it goes away.
Be sure and set the "Window Open Properties" behavior on the button you set up to "Display in a new window" - or they'll close their only window. I open the flow window in top left and set it to 350 x 750 pixels and it's worked pretty well in most cases.
There's a simple 2-step solution that can then be used for all Flows without needing a custom VFP per Interview.
Step 1: Create a VisualForce Page called forceclose
<html>
<head>
<title>ESCAPE</title>
<script>
function closeWindow() {
window.open('','_parent','');
window.close();
}
</script>
</head>
<body onload="closeWindow()">
</body>
</html>
</apex:page>
Step 2: Append the follwing to the end of your interview URLs (good for buttons or links)
Voila! Hitting the finish button will call this VF page that calls the window.close() function and this will dismiss the flow's window/tab.
-
Append &retURL={Object.Id} to the URL on my Custom Button
-
Change the Behavior to "Display in existing window without sidebar or header"
After clicking the button the Visual Workflow takes up the entire screen and the User navigates through the flow. After clicking "Finish" the Visual Workflow window closes and returns to the record and is refreshed.Upon Finish:
1. Close the flow and,
2. Direct User to the specific record they created/udpdated during the flow.
Right now, my URL looks like this where I"m passing a Variable to the Account record:
/flow/Special_Event_Wizard?varaccID={!Account.Id}&retURL=/apex/forceclose
The force Close works but just leaves me on a blank page with the Header and Sidebar. Ideally, I want it to go to the record that was created in the flow.
I have it behaving closer to what I want with one exception now. The parameter I'm passing is in the APEX Page is not correctly populating the lookup field in the record the Flow is creating. This was working correclty when I was launching the flow from a Custom Link URL but when I try to launch the Flow from a VF Page, I see the ID of the variable in the URL above but it isn't passing into the lookup field. The variable in the Flow Designer is set to Input/Output and hasn't changed since I was originally using a custom link URL.
VF Page code:
The varaccID param is what I have defined in the Flow Designer and it is supposed to accept the AccountID. Again, I can see it in the URL when I launch the Flow from the VF link but just isn't populating the Variable in my flow correctly
<apex:page standardController="Account" recordSetVar="Accounts" extensions="Account_Controller"> <flow:interview name="Special_Event_Wizard" finishLocation="{!URLFOR('/home/home.jsp')}"> <apex:param name="varaccID" value="{!Account.id}"/> </flow:interview> </apex:page>
No worries if you aren't sure. I will somehow figure this out.
Thanks Again.
There's an example of this here (https://www.salesforce.com/us/developer/docs/pages/Content/pages_flows_advanced.htm) (about 3 code-snippets down): Cheers, and happy coding!
Here is the syntax for the URL behind my custom button:
Below is the code behind my the ForceClose VF Page: Hope this helps!
I know this is a long shot, but when you go to Setup > Security Controls > Session Settings > Clickjack Protection, is anything checked there? I am wondering if it has something to do with clickjack protection.
Eric
<flow:interview name="MyFlow" finishLocation="{!URLFOR('/apex/ForceClose')}">
I thought Eric's comment about clickjack protection may have been right about the reason for it not working in Megan's case - however I enabled clickjack protection for visualforce pages and it still worked.
I have this nearly working. So thanks @James.Molloy My custom button is calling my flow and then closing the pop up window by calling the vf page as above. However now I need the page to refresh so the new data inputted by the flow takes effect.
I guess I need this somewhere but unsure where? document.location.reload(true) In the VF page code somewhere?
Any ideas?
I am trying to edit the vf page to reload when the windo closes but is returning to the home page and not to the parent window. Any ideas?
/flow/New_Service_Request?retURL=apex/flowforceclose
Great solution, James!