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
Naresh Kumar Mohan ThirukkovaluruNaresh Kumar Mohan Thirukkovaluru 

hi all, i am unable to redirect to detailed page of record after saving it & code for new,cancel.

public with sharing class bookclass {
    
     public bookclass(){
     name1=' ';
     price1=null;
     author1=' ';
     edition1=null;
     }
    
     public String name1 { get; set; }
    
     public decimal price1 { get; set; }
    
     public String author1 { get; set; }
    
     public decimal edition1 { get; set; }
    

    public PageReference save() {
    book__c bk = new book__c();
    bk.name=name1;
    bk.bookprice__C=price1;
    bk.author__C=author1;
    bk.edition__C=edition1;
    insert bk;
   
        return null;
    }


    public PageReference saveandnew() {
        return null;
    }

     public PageReference cancel() {
        return null;
    }

}
Ramesh KallooriRamesh Kalloori
public PageReference save() {
    book__c bk = new book__c();
    bk.name=name1;
    bk.bookprice__C=price1;
    bk.author__C=author1;
    bk.edition__C=edition1;
    insert bk;
   PageReference pobj=new PageReference('/apex/PageName');
          pobj.setRedirect(true);
        return pobj;
    }
give the pageName as you want redirect to.

thanks,
Ramesh
Naresh Kumar Mohan ThirukkovaluruNaresh Kumar Mohan Thirukkovaluru
thanks for reply sir how about save&new, cancel code   Thanks & Regards Naresh Kumar
Ramesh KallooriRamesh Kalloori
if you want do this for save&new and cancel follow the same above other wise do the below it will redirect the same page.

public PageReference saveandnew() {
        return null;
    }

     public PageReference cancel() {
        return null;
    }
thanks,
Ramesh