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
MikeyJamJamsMikeyJamJams 

How to Refresh a Parent Page when deleting records from an Embedded VisualForce table.

I've created a VisualForce page that I have embedded on the Account Page Layout. It serves as a custom Opportunity Related List, with the ability to Edit and Delete Opportunities. Whenever I delete Opportunities, my JavaScript action function is set up so that the VisualForce form refreshes and the deleted record is no longer visible. However, how can I refresh the Account Page in which the VisualForce is embedded. 

 

From looking at code, it seems it has to potentially do with the reRender attribute, but I'm not sure if the reRender attribute only affects the embedded VisualForce page. Here is the code I have for my embedded VisualForce.

<apex:page standardController="Account" extensions="opportunityRelatedList,deleteOpportunityRelatedListRecords">
<apex:form id="form">
    <apex:pageBlock title="Large Opportunities">  
        <apex:pageBlockTable value="{!FilteredOpportunities}" var="opp">        
            <apex:column >
                <apex:outputLink value="/{!opp.id}/e?retURL=/{!opp.AccountId}" target="_parent"> Edit </apex:outputLink>&nbsp;|             
                <a href="Javascript&colon;if (window.confirm('Are you sure?'))JSDeleteRecords('{!opp.Id}');"> Del </a>                                                             
            </apex:column>          
            <apex:column value="{!opp.Name}" />
            <apex:column value="{!opp.Amount}" />
        </apex:pageBlockTable>
    </apex:pageBlock>

<apex:actionFunction name="JSDeleteRecords" action="{!DeleteRecords}" reRender="form">   
    <apex:param name="oppID" value=""/></apex:actionFunction>   
</apex:form> 
</apex:page>

 

Do I need to put some JavaScript command in the rerender attribute so that the Account page will refresh?

Thanks!

Mikey

The KnightThe Knight

Yes you need javascript and this shold be in 'OnComplete' event.

try this window.opener.location.href='/<Your AccountId>'

MikeyJamJamsMikeyJamJams

Hey Knight,

 

I was hoping I might be able to do something with the OnComplete event, and I've put in the JavaScript you recommended, but unfortunately it's not working.  Here's what I have:

oncomplete="window.opener.location.href='/001d000000IRDxj'"

 I still have the same outcome, where the form itself on the embedded VisualForce refreshes, but the entire page won't refresh.

 

Instead of hardcoding the ID, i used a variable, but when that wasn't working, I tried hardcoding the Account ID as shown above. I even tried modifying the JavaScript to:

window.opener.parent.location.href, but still got no results.

 

Is there something else you think i could try?

 

Thanks,

Mikey