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

Overridding Delete button to add extra step before deleting



I want to override the Delete button to add addition step before deletion.


Account is related to an custom object


1) if user goes to delete the custom object relationship then

2) user should be promoted with a VF page where he has to lookup a contact to assign his cases to another user.




How can I get the Id of deleting record using overridding button?




Goto Setup -> Creeate->Object -> "Select your Object" ->Standard  Buttons and Links -> Edit Delete Button


Select Visualforce page and select your VF page in the drop down


To get the ID:


declare a variable with needed fields in your controller that points to the current record

then you can reference those field in your VF page and controller.


Hi ,


Thanks for your reply!


But I want to capture Id of deleting record and use it in some VF manipulation.


How to create that button so that I can get the ID.




I edited my post after rereading yours.


You basically set the Delete button to a visualforce page and then do all your work on the VF page and controller.


How familiar are you with VF? If not too familiar I can give you a quick example...I am new at this as well but I have got this part down I think thanks to help from the good folks here.


Thanks !


That would be great if you can help me capturing the Id of the deleting record and passing it in VF page.


Actually I have limited exposer therefore struggling to get it.


Below if my requirement.



Account: Salesforce

Contact: Mr. Salesforce


Another Account:


Custom object containing relationship will show :  Mr. Salesforce  with

they have cases in the system


now if some one want to delete this relationship then I want to show a VF page where user can select the another contact and assign all cases of above relation cases to the select user.




I do not think that would be related to the Delete button. The delete button would delete the case, contact, or account record not the relationship.


I know there is a quick and easy way to do this via a visualforce page and I think one of the great super contributers here has an easy solution to this.


As I understand it you basically want to:


1. Find all cases related to account Salesforce AND

2. reassign those cases to another contact from Salesforce? or another contact from any account?


Also, is your custom object a custom junction object linking the two account to the case?




Yes its a junction object between contact and account.


I just need help in capturing Id of record(junction object ) to pass on VF page.




How about:


on the controller:


Declare variable to hold account ID


        Public Account thisAccount; (this assumes the standard coltroller is the Account)


during the initializatin of the controller:



public List<'api of junction object'> getoJunction(){


return [Select id From 'api of junction object' WHERE SalesforceID =: thisAccount.Id};



Then on your VF page you can reference the {!oJunction.Id} to return the Id of the account link on the junction object.


Please someone correct me or clean this up a bit if needed.