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
shra1_devshra1_dev 

how to redirect to VF page on save button click

Hi,

 

how to redirect to a vf page when the record is saved(when updated) in Standard Edit Page of an object?

 

here when i am editing a record in standard edit page of an object and clicking the save button It should redirect to a vf page.

 

How to do this?

 

Please help me........

GoldwinGoldwin

try something like this,

 

 

public PageReference cancel() {
            PageReference opportunityPage = new ApexPages.StandardController(opportunity).view();
            opportunityPage.setRedirect(true);
            return opportunityPage; 
    }

If you need to redirect to custom page, if the custom VF page name is customPage

 

 

 PageReference customPage = Page.customPage;
  customPage.setRedirect(true);

 

 

 

 

 

shra1_devshra1_dev

Hi goldwin,

 

Thanks for quick reply...

 

I think u did not understand my problem..

 

Actually I am creating a VF Page Which displays the List of records of my custom object and I hav define edit action on each row. When Edit is clicked it will go to the Standard Edit Page of that object. I am modifying the data over there and when I click save then the record should updated and redirected to VF page again.

 

how to override the save button code with our code

Imran MohammedImran Mohammed

What you should do is , goto setup --> create --> objects -->yourobject.

scroll down to standard buttons and links section.

Edit View link there and override with VF page you have created.

Imran MohammedImran Mohammed

As much as i know, for this you need to override the Edit page functionality.

naresh johnnaresh john

HI

I want to redirect to a web tab. Really I am unable to do it. Even I unable to find relevant information.

 

How to get web tabs Id, in a apex class.

 

Thanks,

Naresh

Imran MohammedImran Mohammed

To redirect to Web tabs, you should copy the relative path when you access the Webtab URL i.e. from /servlet/servlet.Integration?lid=idval&ic=1 and create a pagereference with that.

That will take navigate you to Webtab.

 

Imran MohammedImran Mohammed

Naresh to make it clear. you should first click on the Web tab and from address bar you have to copy the part which i mentioned. Hope this will help as i did earlier the same for SControls

Imran MohammedImran Mohammed

Were you able to get this done or still you are facing any issues?

naresh johnnaresh john

HI Imran,

 

     I think its not possible. By big problem is getting web tabs Id by its name in apex class.

 

I did this requirement.by giving static url. But I need to upload this to package. Thats why I need to make it dynamic link.

 

 

Thanks,

Naresh

Imran MohammedImran Mohammed

Dont directly use the url in Apex class.

In VF page have a apex:hidden tag and assign the URL to it in Javascript code using document.getElementByID.

Then use the value in Apex class.

If you use URL value that contains id in Apex class, you may face a problem when you install this app and access the page. It may not work

If you do that in VF Javascript, it will work.

 

sampath thylaksampath thylak

Your Save Button Action like this

 

            <apex:commandButton action="{!CustomSave}" value="Save"/>


 Then write the Controler for the Save Button as i given below

 

public PageReference CustomSave()
    {
        insert survetq;

        String ParentId = System.currentPageReference().getParameters().get('parameter');

        //String ParentId = System.currentPageReference().getParameters().get('CF00N90000001y40x');
         PageReference redirecturl = new PageReference('https://pet-developer-edition.my.salesforce.com'+ParentId);
         return redirecturl;
    }

Now after click the save Buttonthat page Reditrect into Following page

     https://pet-developer-edition.my.salesforce.com/a0P90000000mG3Y