You need to sign in to do that
Don't have an account?
Ola Bamidele
How to display a "Successfully Submitted" message after my form is filled out
Hi Gurus,
i've created a VF and Apex page to display a form on a Site that is linked to a custom object in Salesforce. After the form is completed, the user is then redirected to my website.
However, how can I add a "Thank you, you have successfully submitted the form" page before the user is redirected to my website?
Please if you have an idea of how this can be achieved, please let me know.
This is my visualforce page:
<apex:page standardController="Turndown__c" sidebar="false" showHeader="true" extensions="extencntrl" >
<apex:form >
<apex:pageBlock title="Documented Turndowns" id="turndown_list">
<apex:pageBlockSection columns="1" >
<!-- to remove the header, but keep the fields' help texts -->
<style type="text/css">
.bPageHeader {display: none;}
</style>
<!-- Inputfields -->
<apex:inputfield value="{! Turndown__c.Account__c }"/>
<apex:inputfield value="{! Turndown__c.Phone_Number__c }"/>
<apex:inputfield value="{! Turndown__c.Region__c }"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:actionStatus id="go">
<apex:facet name="stop">
<apex:commandButton value="Save" action="{!Save}" status="go" disabled="false" rerender="go"/>
</apex:facet>
<apex:facet name="start">
<apex:commandButton status="go" value="Saving..." disabled="true" />
</apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
apex code:
public with sharing class extencntrl{
Turndown__c turnd;
public extencntrl(ApexPages.StandardController controller) {
this.turnd= (Turndown__c)controller.getRecord();
}
public pageReference save()
{
Insert turnd; // steps to save your record.
Pagereference pgref = New PageReference(Label.WebsiteURL);
return pgref;
}
}
Thank you very much!
i've created a VF and Apex page to display a form on a Site that is linked to a custom object in Salesforce. After the form is completed, the user is then redirected to my website.
However, how can I add a "Thank you, you have successfully submitted the form" page before the user is redirected to my website?
Please if you have an idea of how this can be achieved, please let me know.
This is my visualforce page:
<apex:page standardController="Turndown__c" sidebar="false" showHeader="true" extensions="extencntrl" >
<apex:form >
<apex:pageBlock title="Documented Turndowns" id="turndown_list">
<apex:pageBlockSection columns="1" >
<!-- to remove the header, but keep the fields' help texts -->
<style type="text/css">
.bPageHeader {display: none;}
</style>
<!-- Inputfields -->
<apex:inputfield value="{! Turndown__c.Account__c }"/>
<apex:inputfield value="{! Turndown__c.Phone_Number__c }"/>
<apex:inputfield value="{! Turndown__c.Region__c }"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:actionStatus id="go">
<apex:facet name="stop">
<apex:commandButton value="Save" action="{!Save}" status="go" disabled="false" rerender="go"/>
</apex:facet>
<apex:facet name="start">
<apex:commandButton status="go" value="Saving..." disabled="true" />
</apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
apex code:
public with sharing class extencntrl{
Turndown__c turnd;
public extencntrl(ApexPages.StandardController controller) {
this.turnd= (Turndown__c)controller.getRecord();
}
public pageReference save()
{
Insert turnd; // steps to save your record.
Pagereference pgref = New PageReference(Label.WebsiteURL);
return pgref;
}
}
Thank you very much!
Try Changing the Save method to this. It is working fine in my Org. Note: When you will give the website Url in Custom Label, give the complete link. Eg :
Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards ,
Suraj
All Answers
PageReference pgref = new PageReference(Label.WebsiteURL);
pgref.getParameters().put('message', 'Your Message here');
pgref.setRedirect(true);
return pgref;
Please Try this code :
Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards ,
Suraj
Thanks for your response however I tried the code and it didn’t work – though it saved correctly.
Thanks for you response however when I enter the Outputpanel, I get an error saying:
“Unknown property 'Turndown__cStandardController.displayPopUp”
I have made few code changes. I have made a class with name Accounttest.
VisualForce Page :
Apex Class :
Screenshot :
Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards ,
Suraj
Thanks for the reply but your code doesnt work. I firstly cant change my standard controller as that will could my form to stop working correctly. If you could make the additional changes to the original code I posted that would be great as youll understand better, thanks!
Hi Ola Bamidele,
I have made the change in your code and it is working fine in my Org.
VisualForce Page :
Apex Class :
Screenshot :
Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards ,
Suraj
Yes thanks the pop up is now working. However after the record is saved, the page is suppose to be redirected to the "Label.WebsiteURL" inside the the New PageReference. How can I add the "Label.WebsiteURL" to the code so that it will be redirected to the website after the record is saved?
Thanks very much!
Try Changing the Save method to this. It is working fine in my Org. Note: When you will give the website Url in Custom Label, give the complete link. Eg :
Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards ,
Suraj
Its now redirecting to the custom label as wantes.
Thanks very much for the help.
Do you know how I can redirect to another visualforce instead of the "Label.Website" (which is a webpage)?
Is it as simple as I will need to put the visualforce page name in the body of the labelI created?
Or will I need to do something else aswell?
Thanks