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
fourfourfunfourfourfun 

Save & new OR Save and display saved record controller

Hi,

 

Am in the unenviable position of trying to edit someone elses code. They have made a Save and Exit controller that saves on a Visualforce page and exits to the custom object list screen.

 

What I want to do is create a couple of variants.

 

1) Save & New

2) Save and display saved record

 

This is what I have so far

 

public pagereference mySave()
    {
        pcmAct = (PCM_Time_Record__c)stdCtrl.getRecord();
        if(pcmAct.type__c == '121 Call')
        {
            for(PCM_Activity_Attendee__c a:attendees)
            {
                a.one_to_one__c = true;
            }
            
        }
        update attendees;
        pagereference savepage = stdCtrl.save();
        return savepage;
    
    }

 What can I do to amend this?

sfdcfoxsfdcfox
That's a reasonable "save and display saved record" function, although you'll want to add error checking in case "update attendees" fails because of validation rules, etc.

The "save and new" variant could simply call "mySave()" directly, check to see if the return value was null, and if not, then return them to a new record page.