Custom Cancel Button Action

Sometimes you may not be able to use the standard controller “cancel” page action, so you can easily replicate the behavior using the below snippet. ┬áThis will return the person to the object record.

Visualforce Code:

<apex:commandButton action="{!actionCancel}" value="Cancel"/>

Apex Code:

public PageReference actionCancel() { 
    PageReference page = new PageReference('/'+objectRecord.Id);
    return page;


Leave a Reply

Your email address will not be published. Required fields are marked *