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
Parmeshwar Bhore 1010011Parmeshwar Bhore 1010011 

Restrict Trigger Deletion On Note Object With his Test Class

Write a trigger for befor delete on Note Object And Test class for that Trigger. give any solution.
AnudeepAnudeep (Salesforce Developers) 
Here is a sample code

Trigger
trigger DeleteNote on Note (before delete) {
    if(Trigger.isDelete && Trigger.isBefore){
        for(Note N : trigger.old){
            N.adderror('Note Cannot be deleted');
        }
    }
}

Test Class
@isTest
public class AddQAAMWeeklyPlannerTest {
    
    static testmethod void saveAllDetails()
    {
        Account acc = new Account(); 
        acc.name = 'test'; 
        insert acc;
        Note n = new Note(); 
        n.title = 'test'; 
        n.parentId = acc.Id;
        insert n; 
        delete n;
}
}

Please make changes as per your needs

If you find this information helpful, please mark this answer as Best. It may help others in the community