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
Mostafa Matar 4Mostafa Matar 4 

Visualforce page save button not saving new record

Hello,
I have a custom object, Survey, and I have created a visualforce page to show a customized UI. I successfully linked it to a custom button to be used for creating a new record and it displays correctly but hitting the save button doesn't save the record.
No errors are displayed instead, the page redirects to the previous page.
This is my code:
 
<apex:page standardController="Survey__c" recordSetVar="surveys">
    <apex:pageMessages />
    <apex:form >
        <apex:pageBlock title="Create a new survey">
            <apex:pageBlockButtons >
                    <apex:commandButton value="Save" action="{!save}"/>
                    <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">
                // The fields go here
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

What could be the issue ?
Best Answer chosen by Mostafa Matar 4
Vasani ParthVasani Parth
Mostafa,

Can you please let us know the controller class ? Thanks !

All Answers

Vasani ParthVasani Parth
Mostafa,

Can you please let us know the controller class ? Thanks !
This was selected as the best answer
VineetKumarVineetKumar
Can you check if any required field is missing before you click on 'Save'.
If you are using <apex:inputField> tag and if reRenders are not handled properly, you might not be able to see the error message on the page.
Also, I would suggesst you to check the debug logs for any such error.

Let me know if that helped.
Mostafa Matar 4Mostafa Matar 4
Thank you both guys for your replies and the problem was in the controller class as suggested by Vasani.
VineetKumarVineetKumar
That's interesting, cos there is no controller class in your page, you are just using a standard controller.