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
MktdevMktdev 

Overridding Delete button to add extra step before deleting

Hi,

 

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.

 

Query:

 

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

 

 

Starz26Starz26

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.

MktdevMktdev

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.

 

 

Starz26Starz26

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.

MktdevMktdev

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.

 

Example:

Account: Salesforce

Contact: Mr. Salesforce

 

Another Account: Force.com

 

Custom object containing relationship will show :  Mr. Salesforce  with force.com

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.

 

 

Starz26Starz26

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 Force.com

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?

MktdevMktdev

Hi,

 

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.

 

Regards,

Starz26Starz26

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:

 

         thisAccount=(Account)controller.getRecord();

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.