In this code it should save and redirect to a page called pitu3. when i click on save it does not save anything. Any body know why? Thanks

public class test1 {

    public Product_Brief__c pb {get;set;}
    public User u {get;set;}

    private ApexPages.StandardController controller {get;set;}
    public boolean bUpdate {get;set;}
    public string loggedinUserId = UserInfo.getUserId();
    public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];

    public String ctId{
        get {
         //   if (ctId==null){
         //   if (bUpdate){
                  ctId = u2.ContactId;
         //       }
              return ctId;
         //   }

    Contact ct = [SELECT AccountId FROM Contact WHERE id=:ctId];
    public string getacct(){
        Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];  
        return acct.Name;
        return null;

    Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];

   /* public PageReference save() {
    return null;

    public PageReference save() {
    if(controller.save() != null) {
    PageReference congratsPage = Page.pitu3;
    return congratsPage;
    return null;


    public test1(ApexPages.StandardController controller) {
        this.controller = controller;

    public PageReference page1(){
    return Page.pitu1;

    public PageReference page2(){
    return Page.pitu2;

    public PageReference page3(){
    return Page.pitu3;

    public PageReference page4(){  
    return Page.pitu4;

    public PageReference page5(){
    return Page.pitu5;

  • 1
    Do you have an <apex:pageMessages /> tag in your VF page? If not, add one so that you can see any error messages which may be presented. If you're using any rerenders, make sure you rerender the <apex:pageMessages /> tag in addition to whatever else needs to be acted upon. – Mark Pond Jun 26 '15 at 22:57
  • What doesn't it save? You're querying a lot of objects in your controller, do its hard to tell what's actually going on without your Visualforce page. You only call save() on the StandardController that you pass in so I would only expected the record that it refers to to be updated and nothing else (eg. your Product_Brief__c pb wouldn't be created/updated). Can you post your Visualforce page and explain a bit more about what you expect to happen? – Alex Tennant Jun 27 '15 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.