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
Ron MaffrandRon Maffrand 

how to prevent the final Solution record from deleting for the parent Opportunity record.

How do I prevent the final Solution record in a list of solution records from deleting for the parent Opportunity record?
Steps suggested by a developer as follows:
>>create a trigger on Solution Record object on before delete event
>>Fetch the details of the parent opportunity record using the id of the solution record
>>check the number of solution record associated wit the opportunity.
>>if the result is one it means that this solution record is the last record and display an error message.
>>if the result is more than one allow to delete the record.

Anybody have sample code to do this or similar example?