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
Sibanee purohitSibanee purohit 

How to deactivate a record after clicking a custom button?

In my scenario I have some records and I need to create one custom button in detail page,by clicking that button that record should be deactivated or disabled...How can I achieve that functionality..Please help me
Best Answer chosen by Sibanee purohit
Narender Singh(Nads)Narender Singh(Nads)
Hi Sibanee,
You can't disable that edit button. What you can do is remove that Edit Button from that page layout which you are assigning at the click of your custom button.

All Answers

Narender Singh(Nads)Narender Singh(Nads)
Hi Sibanee,
Did you mean record type? Because there is no such thing in salesforce called 'deactivate a record'. Though, you can lock the record. But you can't 'deactivate or disable' it.

Thanks
Sibanee purohitSibanee purohit
I need to create a custom button called Colse.After clicking the button that the edit functionality shouldn't be there that means that record should be locked or the standard button Edit should be disabled or the record detail page should be readonly.How would I acieve any of this functionality?
GhanshyamChoudhariGhanshyamChoudhari
  1. create a read-only page layout.
  2. create one record type and assign read-only page layout.
  3. on button click change the record type to newly created record type.
Sibanee purohitSibanee purohit
yes.We can do that but after assigning the pagelayout to the dummy recordtype still the edit button is accessible.using that we can edit the record and I want to disable edit property.
 
Narender Singh(Nads)Narender Singh(Nads)
Hi Sibanee,
You can't disable that edit button. What you can do is remove that Edit Button from that page layout which you are assigning at the click of your custom button.
This was selected as the best answer
Sibanee purohitSibanee purohit
okay..Can you tell me how to go to that record type after clicking button?
 
Narender Singh(Nads)Narender Singh(Nads)
Hi,
For that you will have to write a javascript code for custom button, using that you can pass the ID of that record to an apex class where you will write your logic to assign the New read-only type page layout to your user.

Thanks
GhanshyamChoudhariGhanshyamChoudhari
once you have multiple record type in one object then Change Record Type will be available under a page layout >button
Sibanee purohitSibanee purohit
Hi 
I created that button and by clicking it is redirecting to the readonly page.This is my code which I have written in detail page button,content source is Onclick javascript.Now I want to disable the 'Close ' button after clicking it once.For that I wrote a vf page and put that link here but it's going to vf page after clicking close button.How to disable this button ?

 {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
fuction validate()
{
var oppObj = new sforce.SObject("Open_Selection__c"); 
oppObj.Id = '{!Open_Selection__c.Id}'; 
oppObj.Status__c = "Closed";
oppObj.RecordTypeId = '0126F000001YdAb'; 
var result = sforce.connection.update([oppObj]); 
 
if (result[0].success=='false') {
     alert(result[0].errors.message);
} else {
     location.reload(true);
     
     

}
}