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
SAHG-SFDCSAHG-SFDC 

How to redirect to the address from the command button

Hi , I am trying to acheive a functionality where I want to redirect the user to a particular page, I was able to do that using a link, I want to do it with a button
<apex:outputLink value="/oppitm/multilineitem.jsp?oppId={!Opportunity.id}&retURL={!Opportunity.id}" target="_top" style="color:blue ;" >Edit All</apex:outputLink>
Any suggestions?
brahmaji tammanabrahmaji tammana
You can try using pagereference.

Simple pagereference for your information:

Page:
<apex:page controller="redirect">
	<apex:form>
    	<apex:commandButton value="Redirect" action="{!redirecturl}" />
	</apex:form>   
</apex:page>


Controller:
public class redirect {    
    public pagereference redirecturl(){
        //Write your original code here
        return Page.hello5; //Sample test page, you give your original url/page
    }
}

Hope it helps.

Regards,
Brahma
YogeshMoreYogeshMore
Hello SAHG,

You have used form tag <apex:form> in your page, add “id” attribute like <apex:form id="frm">

Then add following code in your VF page.

 <apex:commandButton value="Edit All" onclick="window.open('/oppitm/multilineitem.jsp?oppId={!Opportunity.id}&retURL={!Opportunity.id}','_self')" reRender="frm"/>
 
Regards,
Yogesh More
Salesforce Consultant || Salesforce Developer
 more.yogesh422@gmail.com || +919096872010
www.yogeshmore.com || Skype:-yogesh.more44
 
SAHG-SFDCSAHG-SFDC
HI Thank you so much for responding

@YogRag, I am trying to use your solution, It works as expected , except this is an inline VF page so the new page opens in the inline area, it needs to open in the same window full page

How to acheive that?

Advance thanks :)
YogeshMoreYogeshMore
Hi.

Following code helps you to achieve requirement.

<apex:commandButton value="Edit All" onclick="window.open('/oppitm/multilineitem.jsp?oppId={!Opportunity.id}&retURL={!Opportunity.id}','_parent')" reRender="frm"/>

If your problem is solved then mark it as best answer.
 
Regards,
Yogesh More
Salesforce Consultant || Salesforce Developer
 more.yogesh422@gmail.com || Skype:-yogesh.more44
www.yogeshmore.com 

 
SAHG-SFDCSAHG-SFDC
I was able to add that , I added _Top , It works, One other question this button is rendered on the top left of the page looks odd, I want it to be displayed at the bottom
YogeshMoreYogeshMore
Can you share your code? It helps to solve your problem.