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
MattymooMattymoo 

How to display a simple "Thanks" message on completion of a Sites-based feedback form

Hi

I'm completely new to force.com Sites and VF 

This is my first attempt. I used easypage to generate the VF.

I'm in a prelive sandbox at present.

http://cambridge.prelive.cs13.force.com/AcademicFeedback/a1fW000000006RO

On clicking "Save" it displays the "Authorisation required" page!

It does create the feedback record fine, which is cool!

 

I'd like it to show a simple "Thanks for your feedback" message.

Any idea how you do this?

 

<apex:page standardController="Academic_Customer_Feedback__c" standardStylesheets="{!if($CurrentPage.parameters.css == 'std',true,false)}" showHeader="{!if($CurrentPage.parameters.css == 'std',true,false)}" >
        <apex:sectionHeader title="{!$ObjectType.Academic_Customer_Feedback__c.label} Edit" subtitle="New {!$ObjectType.Academic_Customer_Feedback__c.name}"/>
        <apex:form >
        <apex:pageBlock title="{!$ObjectType.Academic_Customer_Feedback__c.label} Edit" mode="edit">
                <apex:pageBlockButtons >
                        <apex:commandButton action="{!save}" value="Save"/>
                        <apex:commandButton action="{!cancel}" value="Cancel"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection showHeader="true" title="Customer Details" columns="2">
                        <apex:pageBlockSectionItem >
                                <apex:outputLabel value="Academic Customer Feedback Owner"/>
                                <apex:outputText value="{!Academic_Customer_Feedback__c.Owner.Name}"/>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Opportunity__c}"/>
                        <apex:pageBlockSectionItem />
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Contact__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="1. Course Details" columns="1">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Module_Name__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Module_Code__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Level_of_Module__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Number_of_Students__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Module_Start_Date__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Other_Colleagues_involved_in_decision__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Current_textbook_s_in_use__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Local_BookSeller_s__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Your_Email__c}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="2. Your Feedback" columns="2">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Adopted_main_text__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Recommended_background_reading__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Adopted_one_of_two_main_text__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Not_adopted__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Recommended_one_of_several_texts__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="false" columns="1">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Why_are_you_adopting_the_book__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.If_not_adopting_then_why__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Any_Other_Suggestions_for_Improvement__c}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="3. More Information" columns="2">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.What_else_can_Cambridge_do_for_you__c}"/>
                        <apex:pageBlockSectionItem />
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Receive_information_about_related_titles__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="Information" columns="2">
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="System Information" columns="2">
                </apex:pageBlockSection>
        </apex:pageBlock>
        </apex:form>
</apex:page>

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The standard controller save will take you to the view page of the newly created record by default, and you'll need authorization for that.  To work around this, simply create an extension controller that invokes the standard controller save and then redirects to a thanks visualforce page instead of the standard view.

 

Something like:

 

public class FeedbackExt
{
   private ApexPages.StandardController stdCtrl;

   public FeedbackExt(ApexPages.StandardController std)
   {
      stdCtrl=std;
   }

   public PageReference save()
   {
      stdCtrl.save();
      return Page.thanks;
   }
}

 You'll need to create a VF page named 'thanks' and change your main page markup to add the extension controller:

 

<apex:page standardController="Academic_Customer_Feedback__c" 
extensions="FeedbackExt" standardStylesheets="{!if($CurrentPage.parameters.css == 'std',true,false)}" showHeader="{!if($CurrentPage.parameters.css == 'std',true,false)}" >

 

All Answers

bob_buzzardbob_buzzard

The standard controller save will take you to the view page of the newly created record by default, and you'll need authorization for that.  To work around this, simply create an extension controller that invokes the standard controller save and then redirects to a thanks visualforce page instead of the standard view.

 

Something like:

 

public class FeedbackExt
{
   private ApexPages.StandardController stdCtrl;

   public FeedbackExt(ApexPages.StandardController std)
   {
      stdCtrl=std;
   }

   public PageReference save()
   {
      stdCtrl.save();
      return Page.thanks;
   }
}

 You'll need to create a VF page named 'thanks' and change your main page markup to add the extension controller:

 

<apex:page standardController="Academic_Customer_Feedback__c" 
extensions="FeedbackExt" standardStylesheets="{!if($CurrentPage.parameters.css == 'std',true,false)}" showHeader="{!if($CurrentPage.parameters.css == 'std',true,false)}" >

 

This was selected as the best answer
MattymooMattymoo

Perfect solution. Many thanks bob_buzzard.

It is just worth noting that I needed to add the thanks page to site pages list for it to work.