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
vamsi krishna 106vamsi krishna 106 

page reference is not working

pagereference parentpage=new pagereference('/'+id);
i tried like above and below
return new ApexPages.StandardController(oldtisdetails).view();

both are not working please help me..
Both options look fine. I assume you are returning the parentPage object reference in option 1. Do you get an error message? What exactly do you mean when you say both options don't work?

Below is an example of both options which work fine. 

<apex:page controller="mySecondController" tabStyle="Account">
    <apex:sectionHeader title="New Account Edit Page" />
        <apex:pageBlock title="Create a New Account">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
            <apex:pageBlockSection title="Account Information">
                <apex:inputField id="accountName" value="{!}"/>
                <apex:inputField id="accountSite" value="{!}"/>

public class mySecondController {
    Account account;

    public Account getAccount() {
        if(account == null) account = new Account();
        return account;

    public PageReference save() {
        // Add the account to the database. 
        insert account;

        // option 1
        return new PageReference('/' + account.Id);
        // option 2 
        //return new ApexPages.StandardController(account).view();
Amit Chaudhary 8Amit Chaudhary 8
Please try like below code.
return  new pagereference('/'+id);
Please let us know if this will help you
David OvellaDavid Ovella
 Hello vamsi
can you try these codes

Opcion 1
        PageReference pr=new PageReference('/'+olddetailsId);
        return pr;    

Opcion 2
        PageReference OldDetailsPage = new ApexPages.StandardController(oldtisdetails).view();
        return OldDetails;
jyothsna reddy 5jyothsna reddy 5
Hi Vamsi,

Please try this below sample code
Pagereference pr=new pagereference('/';
return pr;
Here "a" is object handler.

Jyothsna D