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
Deepika Gupta 26Deepika Gupta 26 

Not Able to open parent window on click of the link which in VF page

I have a urgent requirement i know its very small thing but i am not able to achieve it.I am on account detail page in this page in this page there is one VF Page means in middle like means division like Account deytails,address information and account hierarchy section now in this account hierarchy section i have a page hierarchy page in this page i have created a link that has to navigate in front of account detail page not on the diffrent tab. i have used 
VF page :
Visualforce Page: HierarchyPage ~ Salesforce - Unlimited Edition<apex:commandLink action="{!doSomething}" target="_self" value="Show_Hierarchy" id="theButton"/>

Controller 

Salesforce - Unlimited Editionpublic with sharing class WithContactButtonController
{
    private ApexPages.StandardController standardController;

    public WithContactButtonController(ApexPages.StandardController standardController)
    {
        this.standardController = standardController;
         System.debug('HelloDeepika');
    }
     public PageReference doSomething()
    {
        // Apex code for handling record from a Detail page goes here
        //Id recordId = standardController.getId();
        PageReference pageRef = new PageReference('/apex/Hierarchy_Clone');

         System.debug('HelloDeepika1');
        return pageRef ;
       
    }

   }

Now the new page that is Hierarchy_clone is opning on that particular section itself of accounthierarachy but i want it to open in the full account detail page not sure how to achieve this.
Rajiv Penagonda 12Rajiv Penagonda 12
Deepika, the reason "Hierarchy_clone" is opening in the same section is because Salesforce renders VF pages added inside Standard Page Layout in their own separate iframes. So any click action inside is handled independently of the main Page Layout logic.

To work around this, you can use javascript. Take a look at the reference code below:
 
<apex:page showHeader="false" sidebar="false" controller="TestAuraController">
    <script>
        function redirectToHierarchyClonePage() {
            var lURL = '/apex/Hierarchy_Clone';
            console.log(lURL);
            window.top.location.href = lURL;
        }
    </script>

    <apex:form>
        <apex:commandLink action="{!save}" value="Show Hierarchy" oncomplete="redirectToHierarchyClonePage();" />
        <input type="button" onclick="redirectToHierarchyClonePage(this);" value="Search" />
    </apex:form>
</apex:page>
In your code, you update your code such that the function "doSomething" in the controller "WithContactButtonController" returns null.

If this helps, you can mark this as best answer.
 
Rajiv Penagonda 12Rajiv Penagonda 12
Did the above solution work for you? Is there something still broken?