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
Rahul H 4Rahul H 4 

Delete trigger

I have to delete the Quote if Quote_Number__c in opportunity is equal to Quote_Number__c in Quotes. Can you please provide a sample trigger for that 
Hi Rahul,

Here is the solution :
trigger deleteQuote on Quote (after insert,after Update) {
   if(Trigger.isAfter && (Trigger.isInsert||Trigger.isUpdate)){
        List<Id> LsDelqtId = new List<Id>();
        List<Quote> lstDelQt = new List<Quote>();
        Map<Id,String> mapQuoteNum = new map<Id,string>();
        set<String> setOppNum = new set<String>();
       For(Quote qt :{
            mapQuoteNum.put(, qt.Quote_Number__c);
          for (Opportunity op: [select id , Quote_Number__c from Opportunity where Quote_Number__c In :mapQuoteNum.values()]){
         if (setOppNum.size() > 0 ){
             for(String Qnum : mapQuoteNum.keyset()){
       lstDelQt = [select id from quote where id in:LsDelqtId];
       Delete lstDelQt;