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
Prasanthi BPrasanthi B 

pagereference for Opportunity Creation is not working

Hi,

I need to redirect a custom button to opportunity creation page.

    Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/e?retURL=%2F0062Fo%');
    system.debug('***optypage****'+optypage);
    optypage.setRedirect(true);
    return optypage;

But the page is not redirecting to the edit page of new opportunity. It remains same on the previous page.

When I remove retURL, it wokrs fine. 

Pagereference optypage = new Pagereference('https:ap1.salesforce.com/006/o');

I need to redirect to the edit page of new Opportunity.

Plesse suggest.

Thanks
Virendra ChouhanVirendra Chouhan
Hi
You want to redirect on opportunity creation page right ?
PageReference pf = new PageReference('https://ap1.salesforce.com/006/e');
        pf.setRedirect(true);
        return pf;

use this code.

Regards
Virendra
Prasanthi BPrasanthi B
Nope. It is not working....staying on the same vf page.
 
Virendra ChouhanVirendra Chouhan
Can you show code snippt ?
Vijay NagarathinamVijay Nagarathinam
Hi,

use the code,
PageReference pf = new PageReference(URL.getSalesforceBaseUrl().toExternalForm()+'/'+ids+'/e';);
pf.setRedirect(true);
return pf;