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
DorababuDorababu 

save functionality not working

Hi friends,

 

I am unable to save a record with the following code. Please help

 

-------------Controller------------------

public with sharing class personAccController {
ApexPages.StandardController con;

public personAccController(ApexPages.StandardController controller) {
con = controller;
}
public pagereference redirect(){
con.save();
pagereference ref= new pagereference('/apex/personaccpage');
ref.setredirect(true);
return ref;
}


}

 

---------------part of page----------------

<apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Save&New" action="{!redirect}"  />
            <apex:commandButton value="Cancel" action="{!Cancel}"/>
        </apex:pageBlockButtons>

 

bob_buzzardbob_buzzard
What behaviour are you seeing? You might want to look at adding an apex:pageMessages tag to your page if you don't already have one, as this will display any errors that occur when attempting the save.
DorababuDorababu
I have written code for 'save and new' as redirect method. Unable to save the record, when attempted saving a record the page is reloaded with the record details entered. Save and new is working fine, facing problem with save
bob_buzzardbob_buzzard

Have you added an apex:pageMessages tag to see if there are any validation errors etc?