You need to sign in to do that
Don't have an account?

Create a new record as a Guest User
Let me begin by saying that I can click to program (not a programmer).
I have designed a very basic survey form that I would like to display to customers so they can submit a review and then be redircted to a thank you page. I do not know how to execute the redirect when they click submit. I am using the following code to Save the record.
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Submit Questionnaire"/>
</apex:pageBlockButtons>
The site is enabled and I can view the form and fill in all of the fields, however, when I click Submit the following error page is displayed, "Page Not Found {VisualForcePage}/{Record ID}"
I know that the guest user doesn't have permissions to view the detail record which is why they receive the "Page Not Found..." message and I don't want them to view it, I want them to be redirected to a second Visualforce Page that essentially says, "Thank You."
Thank you Bulent for the code (can't really claim much of it anymore :) )
The completed code is below with a couple of additional lines. I received an error message stating, "System.NullPointerException: Attempt to de-reference a null object" So I went back to rereading and chapter 12 (pg 367) in the Developer Guide linked the current record used by the standard controller with the new controller from the extension and I hadn't done this.
Thank you for the extensive assistance, now I just need to figure out why after packaging the survey app the Site Url doesn't work within my developer account.
thanks again,
james
All Answers
Thanks Bulent,
I had read the chapter and completely overlooked the Apex extension. I knew it had to be simple, just didn't read carefully.
james
I spoke to soon, still not solved :smileysad:
I realize now I need to extend the standard controller per the example in chapter 14. My need though is much simpler, all that I want it to accomplish is save a single record and redirect to a thank you page...It redirects correctly, however, it doesn't save the record.
I know I'm having issues around lines 4 and 5, but don't know how to change it.
thanks for any assistance.
Can you show us your form (full source code of your visual page)?
It's likely you didn't bind your form variable to a field of your object.
Thanks for the response, the code is below. I didn't include all of the pageBlockSection pieces of the code because they are all similar to the one that I did provide. The pageBlockSections all contain simple multi-select picklists with values 1-5.
<apex:page sidebar="false" showHeader="false" standardController="Survey__c" > <!-- Introduction --> <apex:image id="RRLogo" <apex:form> <apex:pageBlock title="Conference Questionnaire" mode="edit"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Submit Questionnaire"/> </apex:pageBlockButtons> <apex:PageBlockSection title="General" collapsible="false" columns="2"> <apex:inputfield value="{!Survey__c.ReadRightClient__c}"/> <apex:inputfield value="{!Survey__c.howDidYouHear__c}"/> </apex:PageBlockSection> <apex:PageBlockSection title="Pre-Arrival" collapsible="false" columns="2"> <apex:inputfield value="{!Survey__c.Question_1_1__c}"/> <apex:inputfield value="{!Survey__c.Question_1_2__c}"/> <apex:inputfield value="{!Survey__c.Question_1_3__c}"/> <apex:inputfield value="{!Survey__c.Question_1_4__c}"/> <apex:inputfield value="{!Survey__c.Comments_1_0__c}"/> </apex:PageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
thanks,
james
if this is the save code
public class PublicSurveyExtension
{
public PublicSurveyExtension
(ApexPages.StandardController stdController) {
}
private final Survey__c Survey;
public PageReference save()
{
PageReference p = Page.publicthankyou;
p.setRedirect(true);
return p;
}
}
I don't see any record being created. the above code only does the redirect
try the following controller extension instead
public PageReference save() {
try {
insert(Survey);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.publicthankyou;
p.setRedirect(true);
return p;
}
Also, you need to update your visualforce header to reference the controller extesion
<apex:page sidebar="false" showHeader="false" standardController="Survey__c" extensions="PublicSurveyExtension">
Thank you Bulent for the code (can't really claim much of it anymore :) )
The completed code is below with a couple of additional lines. I received an error message stating, "System.NullPointerException: Attempt to de-reference a null object" So I went back to rereading and chapter 12 (pg 367) in the Developer Guide linked the current record used by the standard controller with the new controller from the extension and I hadn't done this.
Thank you for the extensive assistance, now I just need to figure out why after packaging the survey app the Site Url doesn't work within my developer account.
thanks again,
james
Good. there is a reason why I'm not a developer :)
Package/site related isssues will be fixed with the coming summer09 release
Except the home page you can refer to your pages like<developer_name>__<page_name>