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
ryan-davidryan-david 

VF page Save Button not saving and returning to page

Very much a newbie to code and this level of Admin as I have a helper who is much stronger than I. But he's unavailable due to illness. I have a VF page to access a field set to turn a contact into a sponsor, we're a NFP. But on clicking save nothing happens. The fields are not updated and it doesn't return to the main contact page layout. The cancel button works fine... Any help appreciated.

<apex:page standardcontroller="Contact" >
    <apex:form >
        <apex:pageBlock title="Convert_To_Sponsor" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:repeat value="{!$ObjectType.Contact.FieldSets.Convert_To_Sponsor }" var="field">
                    <apex:inputField value="{!Contact[field]}" />
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <apex:detail subject="{!$CurrentPage.parameters.cId}" title="false" relatedList="false" />
Best Answer chosen by ryan-david
William TranWilliam Tran
From a syntax perpective nothing is wrong.  I bet you you have a validation rule that is not being satisfied so your save seems like it does not work.  Use this, it will tell you what the error messages are:
 
<apex:page standardcontroller="Contact" >
   <apex:messages />
    <apex:form >
        <apex:pageBlock title="Convert_To_Sponsor" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:repeat value="{!$ObjectType.Contact.FieldSets.Convert_To_Sponsor }" var="field">
                    <apex:inputField value="{!Contact[field]}" />
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <apex:detail subject="{!$CurrentPage.parameters.cId}" title="false" relatedList="false" />
</apex:page>



Thx

All Answers

William TranWilliam Tran
Ryan,

Did the page work before?

FIrst, this is not the complete page,  it is missing code?

Second, how is this page launched?  a button? something else?

Third, when you said nothing happens, what happens? really nothing?  What does page look like after launched?

Last, I would estimate resolving this issue will take 10-15 minutes if I can see or have access to the environment.

Thx

ps. If you are interested about part-time professional services help, feel free to email me.


 
ryan-davidryan-david
The purpose of this field set is to group the contact fields required to convert a regular contact into a sponsor, someone who wants to financially support one of our children.

I made a button for the contact page which loads a VF page which is a field set  above the usual contact fields. I enter some test data in some of the fields and click save. Firefox indicates something is happeneing on the page and when the "wheel" stops the fields are still visable and in the same position above the usual contact page fields. If I scroll down I see that none of the data has been transfered to the fields in the contact screen.

If I click the cancel botton the VF page closes and the screen returns to the usual contact page.

Thanks for your help
William TranWilliam Tran
From a syntax perpective nothing is wrong.  I bet you you have a validation rule that is not being satisfied so your save seems like it does not work.  Use this, it will tell you what the error messages are:
 
<apex:page standardcontroller="Contact" >
   <apex:messages />
    <apex:form >
        <apex:pageBlock title="Convert_To_Sponsor" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:repeat value="{!$ObjectType.Contact.FieldSets.Convert_To_Sponsor }" var="field">
                    <apex:inputField value="{!Contact[field]}" />
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <apex:detail subject="{!$CurrentPage.parameters.cId}" title="false" relatedList="false" />
</apex:page>



Thx
This was selected as the best answer
William TranWilliam Tran

Ryan, since you are new to the Developer's Forum, here are some guidelines:

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

This will help keep the forum clean and help future users determine what answers are useful and what answer was the best in resolving the user's issue.

Thanks
 
ryan-davidryan-david
Thanks for your help William, told me what field was missing and have now fixed the issue.

Cya
ryan-davidryan-david
Hi William, Thanks for your help. It showed me the field that was missing. After a couple of tests I relaised it was not editing the contact though, it was saving as a new contact. Any thoughts? Appreciate you help William. Thx