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
Harish1234Harish1234 

how to disable the standard button?

Hi

i have a case(sobject), whenever case is close then i want to disable the edit or delete button how it is possible .. will any one help me
KaranrajKaranraj
Hi Saihareesh - You can edit the close pagelayout under Setup->customize->Case->close page layout. You can remove the Edit and Delete button from the pagelayout and assign to the profile.
ShashForceShashForce
We cannot disbale the button, but we should be able to avoid edits and deletes, and show an error message on the record, using validation rules to avoid edits and triggers to avoid deletes.

Validation rule formula to avoid edits on a closed case:

IsClosed = true

Trigger to avoid edits and deletes on a closed case:

trigger closedcase on Case (before delete, before update) {
    if(trigger.isupdate){
        for(case c:trigger.new){
            if(c.isclosed==true) c.adderror('Closed cases cannot be edited');
        }
    }
    if(trigger.isdelete){
        for(case c:trigger.old){
            if(c.isclosed==true) c.adderror('Closed cases cannot be deleted');
        }
    }
}

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
David "w00t!" LiuDavid "w00t!" Liu
Both solutions are good!

The first will prevent users from even having the edit/delete option, but note that they can still edit/delete if they are not doing it from the page layout (ie list view, related list, api, etc)

The second is more robust and covers all cases, however, users will still see the option to edit/delete (even though it will fail).  You also might need to change the formula to PRIORVALUE( IsClosed) = true