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
kritinkritin 

How to write Delete trigger

How to write before delete trigger on Opportunity and change the record type of Opportunity and prevent it from its actual deletion without adding error in record.

http://boards.developerforce.com/t5/Apex-Code-Development/change-the-Record-type-of-Opportunity-on-delete/td-p/236131

bob_buzzardbob_buzzard

I don't think you'll be able to do this.  The database action that is being carried out is a delete, therefore if you don't want to delete the record, you'll need to make the transaction roll back, and the only way to do this is to apply an error to the record.

 

Can you create a clone of the opportunity and change the record type?

 

Failing that, you could remove the delete permission from all profiles and create your own delete button that actually just changes the record type.