You need to sign in to do that
Don't have an account?
Dave Berenato
Standard Controller Apex Page keeps Redirecting to Record
I have a Visualforce Page with a Standard Controller that comes from a Pop-Up Window that I would love to have either redirect to a Visualforce page or Close the Window onComplete.
Option 1: Close the Window
Option 2: Redirect to a "Thank You" Visualforce Page
The first option, the save Button does nothing, the second option, it redirects to the record. Any suggestions?
Option 1: Close the Window
<apex:page standardController="Account" showHeader="false"> <script type="text/javascript"> function CloseWindow() { window.top.close(); UpdateOpener(); } </script> <apex:form > <apex:pageBlock mode="maindetail"> <apex:pageBlockSection columns="2" title="Seller Info"> <apex:inputField value="{!Account.Seller_1_First_Name__c}"/> <apex:inputField value="{!Account.Seller_2_First_Name__c}"/> <apex:inputField value="{!Account.Seller_1_Middle_Name__c}"/> <apex:inputField value="{!Account.Seller_2_Middle_Name__c}"/> <apex:inputField value="{!Account.Seller_1_Last_Name__c}"/> <apex:inputField value="{!Account.Seller_2_Last_Name__c}"/> <apex:inputField value="{!Account.Intake_Packet_For__c}"/> </apex:pageBlockSection> <apex:pageBlockSection columns="2" title="Listing Info"> <apex:inputField value="{!Account.Listing_Agent__c}"/> <apex:inputField value="{!Account.Co_Listing_Agent__c}"/> <apex:inputField value="{!Account.Intake_Listing_Price__c}"/> <apex:inputField value="{!Account.Intake_RLADate__c}"/> <apex:inputField value="{!Account.Intake_Listing_Percentage__c}"/> <apex:inputField value="{!Account.Intake_Buyer_s_Agent_Percentage__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Generate Packet" action="{!save}" onComplete="CloseWindow();" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Option 2: Redirect to a "Thank You" Visualforce Page
<apex:page standardController="Account" showHeader="false"> <apex:form > <apex:pageBlock mode="maindetail"> <apex:pageBlockSection columns="2" title="Seller Info"> <apex:inputField value="{!Account.Seller_1_First_Name__c}"/> <apex:inputField value="{!Account.Seller_2_First_Name__c}"/> <apex:inputField value="{!Account.Seller_1_Middle_Name__c}"/> <apex:inputField value="{!Account.Seller_2_Middle_Name__c}"/> <apex:inputField value="{!Account.Seller_1_Last_Name__c}"/> <apex:inputField value="{!Account.Seller_2_Last_Name__c}"/> <apex:inputField value="{!Account.Intake_Packet_For__c}"/> </apex:pageBlockSection> <apex:pageBlockSection columns="2" title="Listing Info"> <apex:inputField value="{!Account.Listing_Agent__c}"/> <apex:inputField value="{!Account.Co_Listing_Agent__c}"/> <apex:inputField value="{!Account.Intake_Listing_Price__c}"/> <apex:inputField value="{!Account.Intake_RLADate__c}"/> <apex:inputField value="{!Account.Intake_Listing_Percentage__c}"/> <apex:inputField value="{!Account.Intake_Buyer_s_Agent_Percentage__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Generate Packet" action="{!save}" oncomplete="{!URLFOR('https://corere--c.na50.visual.force.com/apex/thankyou')}" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
The first option, the save Button does nothing, the second option, it redirects to the record. Any suggestions?
I trust you are doing very well.
If you don't wish to redirect to record detail page, use the quickSave method instead. Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Option 1: Close the Window
Option 2: Redirect to a "Thank You" Visualforce Page
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas