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
RevanthRevanth 

Performance issue in saving a record and redirecting the page.

Hi I have a vf page which will be redirected when i click the link in opportunity detail page.

 

 

My client has two operating companies which uses the same salesforce application with little changes.

 

Now one opco(operating company) asked the vf page to be on the opportunity detail page instead of a link which will redirect to a vf page and the other opco do not want this.

 

I used to get the inline= true error when i moved the vf page into the detail page, so i used the java script code to make the inline stop and the page will redirect once all the execution is done.

 

Now due to this java script the execution process is so slow that it will take 7 to 10 seconds and if i remove this it will execute in 5ms to 1 sec. Please See the code and suggest me any work around.

 

Vf page: 

 

 

<apex:commandButton value="Save" action="{!saveData}" reRender="redirectSave,Status,MyMessage" status="Status"/>

<apex:outputPanel id="redirectSave">
<apex:outputText rendered="{!shouldRedirect}">
<script type="text/javascript">
window.top.location="{!redirectUrl}";
</script>
</apex:outputText>

 

 

In Controller:

 

 

Public class VView

{

private ApexPages.StandardController Controller;

public Boolean shouldRedirect {public get; public set;}

public machineView2(ApexPages.StandardController controller)

{

this.Controller = Controller;

shouldRedirect = false;

}

public pageReference saveData()

{

shouldRedirect = true; redirectUrl = Controller.view().getUrl(); return null;

}

}

After doing this for both the opcos it will get executed and redirected to the opportunity detail page but it will get executed for 7 to 10 secs.

 

Is there any thing that i need to do to increase the performance of the code(by changing even it it gets executed in 3 to 5 sec it is good).

 

Can any one give suggestions.

 

Thank you,

Revanth Kumar R,