+ Start a Discussion

How to stop loading VF page and display a custom message when record status is approved.

Hi All,


I have overriden the standard salesforce.com Edit button.when status of the record is approved and if user clicks on Edit button he should shown a custom message that record is approved and cannot be edited and VF page should not be loaded.


Can anyone please tell me how this could acheived if you can provide a sample code snippet it will be helpful.





Srilakshmi B

Best Answer chosen by Admin (Salesforce Developers) 

If you are using Approval Processes, you simply need to remove the "unlock record" action from the Final Action section. The record will remain locked, and only administrators will be able to edit the record. Otherwise, you would include the if/then logic in your VF page directly. It would look like this:


<apex:outputText rendered="{!Record.Status__c='Approved'}">
  You can not edit this record.
<apex:outputText rendered="{!NOT(Record.Status__c='Approved'}">
  <apex:form> ... </apex:form>