0

I have added a custom VF page to the quote detail page . enter image description here

And on that VF page there is a button.

Expected : It should refresh the whole page.

Real : It is only refreshing the VF page not the whole page.

vf page:

<apex:page standardController="Quote"  extensions="CustomUnlockQuote" action="{!checkForUser}">
    
    <apex:outputText rendered="{!showButtons}" id="alert">
        <script>
        window.top.location='/{!Quote.id}';
        
        </script>
    </apex:outputText>
    <apex:form >
        <apex:outputPanel rendered="{!showButton}"></apex:outputPanel>
        <apex:commandButton action="{!unlockRecords}" value="testing" />
    </apex:form>
</apex:page>

1 Answer 1

0

The command button would cause the page to refresh, but the script won't necessarily run. You might want to do something like this:

<apex:page standardController="Quote"  extensions="CustomUnlockQuote" action="{!checkForUser}">
    <apex:form id="form">
        <script>
            function possibleRedirect() {
                if({!showButtons}) {
                    window.top.location='/{!Quote.id}';
                }
            }
        </script>
        <apex:commandButton action="{!unlockRecords}" value="testing" reRender="form" oncomplete="possibleRedirect()" />
    </apex:form>
</apex:page>

Some possible further work may be necessary.

We use reRender to avoid a full page VF refresh, which cancels any running scripts (including our intended redirect), and the script itself is inside the form so it gets updated when the showButtons variable is set from false to true.

1
  • Thanks @sfdcfox , reRender did the work May 8, 2021 at 3:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .