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

custom button to call VF Page

I have a reject button that I want to call a VF Page when certain criteria are met,  Everything works fine BUT when you click Save, a new change record ends up being created and thats the page you return to.  I just want the page to save the info you just enetered and return to the same record.


Here's the code right now in the button



VF Page

<apex:page standardController="Change__c" extensions="rejectChange">
<apex:form id="frm"> 
<apex:detail subject="{!Change__c.Id}" relatedList="false" title="false"/> 
<apex:outputPanel id="tstpopup" rendered="{!IF(isDisplayPopUp ==true,true,false)}" > 
<apex:outputPanel styleClass="popupBackground" layout="block" /> 
<apex:outputPanel styleClass="custPopup" layout="block"> 
<apex:pageMessages >
<apex:pageBlock >
<apex:pageBlockSection columns="1" > 
<apex:inputField label="Change Manager Rejected Comments" value="{!Change__c.Change_Manager_Approver_Rejected_Comment__c}" required="true" style="width: 500px"/>

<apex:outputPanel > 
<apex:CommandButton action="{!save}" value="Save!"/> 
<apex:CommandButton action="{!cancel}" value="cancel"/> 


<style type="text/css"> .errorMsg{ width:159px; } 
.custPopup{ background-color: white; border-width: 3px; 
border-style: solid; 
z-index: 9999; 
left: 25%; 
position: absolute; 
width: 1000px; 
//margin-left: -80px; top:100px; margin-left: -170px; 
border-radius: 5px; 


.popupBackground{ background-color:black; opacity: 0.20; filter: alpha(opacity = 20); 
 position: absolute; width: 100%; height: 100%; top: 0; left: 0; 
 z-index: 997 } a.actionlink:hover{ text-decoration:underline; } 
 .customactionLink { color: #015BA7; font-weight: normal; text-decoration: none; } </style> 

      function setFocusOnLoad() { }



public class rejectChange 
public Boolean isDisplayPopUp {get; set;} 
public rejectChange(ApexPages.StandardController controller) 
isDisplayPopUp = true;


 What am I doing wrong?

Best Answer chosen by Admin (Salesforce Developers) 



Try above.

All Answers


Pass record id with the URL



And also add the returl parameter to return it to page you want.

Still not working.  Its still opening a new record and saving the changes in there instead of the existing record and then returning to that new record.  I've changed it to this:







Try above.

This was selected as the best answer
Thank you so much! That works great!