function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ECL47ECL47 

Close VF/Flow and Refresh Parent

I've been reading the other posts, but due to my lack of coding experience (button admin just learning code) I'm having difficulting translating solutions for standard VF pages to my Flow VF page where I have no code for the buttons.

I have a flow which is launched in a new window through a custom link on a custom object. I want the window to close and refresh the custom object page when the flow is completed. I have two VF Pages - The first with the flow, and the second which I am using as a finish location which holds my Javascript currently. I have been able to get the new window to close using the code below, but I have been unsuccessful in getting any code to refresh the custom object/parent window. Any help/recommendations would be appreciated!

Custom Link
/apex/New_PP_with_Listing_Decision_Tree?pba_property_id={!pba__Listing__c.pba__PropertyId__c}

Flow VF Page - New_PP_with_Listing_Decision_Tree
<apex:page showHeader="False" sidebar="False">
  <flow:interview name="New_PP_with_Listing_Decision_Tree" finishLocation="{!$Page.Close}" >
  </flow:interview>
</apex:page>

Javascript VF Page - Close
<apex:page >
    <script type="text/javascript">
        window.close();
    </script>
</apex:page>
harsha__charsha__c
Try this once

Javascript VF Page - Close

<apex:page >
    <script type="text/javascript">
           window.parent.location.reload(); OR window.parent.reload();
           window.close();
    </script>
</apex:page>
ECL47ECL47

With the first suggestion - the window would close but the parent did not refresh

with the second suggestion - the parent did not refresh and the window did not close. Instead, it went to /apex/Close (which is blank)

harsha__charsha__c
Ohhh...! Sorry, it's there should be window.opener instead window.parent

Javascript VF Page - Close

<apex:page >
    <script type="text/javascript">
           window.opener.reload();
           window.close(this);
    </script>
</apex:page>

Regards,
- Harsha
Premasai AchantiPremasai Achanti
I would try this:

Flow VF Page - New_PP_with_Listing_Decision_Tree
<apex:page showHeader="False" sidebar="False">
  <flow:interview name="New_PP_with_Listing_Decision_Tree" finishLocation="/apex/Close?pba_property_id={!$CurrentPage.parameters.pba_property_id}" >
  </flow:interview>
</apex:page>

Javascript VF Page - Close
<apex:page >
    <script type="text/javascript">
        window.opener.location.href="/{!$CurrentPage.parameters.pba_property_id}";
        self.close();
    </script>
</apex:page>
Rens VerhagenRens Verhagen
Tried all above solutions, no luck yet. Does someone have a working solution? :)
Rens VerhagenRens Verhagen
I got this finally working on Chrome, you'll need two visualforce pages and a button. I've created a flow that creates a quote starting from the opportunity. Hope it helps!

Visualforce Close Page:
Name: FlowDesigner_Close_Page
<apex:page>
    <script type="text/javascript">
     window.opener.location.href="{!$CurrentPage.parameters.FinishURL}";
        self.close();
    </script>
</apex:page>
The FinishURL page parameter is used in the next visualforce page. This will reload the starting window with the URL passed in this parameter (could also be another URL).

Visualforce Start Page:
Name: FlowDesigner_Start_QuoteProcess
<apex:page showHeader="False" sidebar="False">
  <flow:interview name="Quote_Process_v4" finishLocation="{!$Page.FlowDesigner_Close_Page}?FinishURL=/{!$CurrentPage.parameters.Opportunity_input_ID}">
  </flow:interview>
</apex:page>
  • 'Quote_Process_v4' is the name of my visual flow.
  • Finishlocation points to the Visualforce Close Page
  • 'Opportunity_input_ID' is an input variable in my flow, I will fill this with the button, see below
Button to Start the flow:
Name: New_Quote
{!$Site.BaseUrl}/apex/FlowDesigner_Start_QuoteProcess?Opportunity_input_ID={!Opportunity.Id}
This button lives on the opportunity and the ID of the current record is passed into: 'Opportunity_input_ID'



 
Karleen MendozaKarleen Mendoza
Thanks for the ideas Rens. Any idea how to do this and maintain the "Lightning" runtime UI?
Rens VerhagenRens Verhagen
Hi Karleen,

Not yet with Lightning Runtime, because you have no Lighnting Runtime with VisualForce as far as I know. I do know that you can embed a Flow into a lightning page (withouf VF) and when this finishes it refreshes the page. Might this be a solution?