I have a VisualForce page that has a custom object as a standard controller (let's call it Custom_Object__c). This page is accessible to the public without having to sign in with any special credentials. The page has a form that allows any user with a link to the form to enter information and submit, thereby updating the record on Custom_Object_c.

Now, suppose the record is deleted. The user still has the link to the form for that particular record, but when they try to access the form after the record is deleted, they would get a "Data Not Available" message (a Salesforce message). Is there a way to override this to show a custom (i.e. more friendly) VisualForce page? Ideally I would want to use the same VisualForce page as the form, with a div that is conditionally shown if the record no longer exists (and also conditionally hides the form).

1 Answer 1


You can easily override the record's view from buttons links and actions with a vf page and redirect the user to show custom message.


Modify the page to show record detail or redirect the user to the actual record if the record is not deleted. I just created a sample page with outputtext to show that you can override the view with any logic to present your message.

<apex:page standardcontroller="contact" extensions="checkrecordvalidity">
<apex:outputText rendered="{!IF(NOT(recorddeleted),true,false)}" value="record not deleted"> </apex:outputText>
<apex:outputText rendered="{!IF((recorddeleted),true,false)}" value="record deleted"> </apex:outputText>


public class checkrecordvalidity {

public boolean recorddeleted{get;set;}
public contact cont{get;set;}
public string conid{get;set;}
    public checkrecordvalidity(ApexPages.StandardController controller) {
                conid = ApexPages.currentPage().getParameters().get('id');
                cont = [SELECT Id, isDeleted FROM contact WHERE Id =: conId  All ROWS];
                if(cont.isDeleted == true){
                    recorddeleted = true;


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .