• Kundan Kumar 118
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi All, 
Here  i trying to write a trigger  when opportunity stage will Closed won...one custom field name Opportunity_Checkedbox__c in account should active. 

it's showing error 

In Line 12 - Comparison arguments must be compatible types: Boolean, String

.....Trigger.....

trigger OpportunityAccTrigger on Opportunity (after Update) {
    
    if(Trigger.isAfter && Trigger.isUpdate){
        OpportunityAccTriggerHandler.afterUpdate(Trigger.new, Trigger.OldMap);
    }

}

...........Trigger Handler......for after update

public class OpportunityAccTriggerHandler {
    
   
    public static Void afterUpdate(List<Opportunity> newList, Map<Id,Opportunity> OldMap){
        set<ID> ids = new Set<ID> ();
        Map<Id,Boolean> OppToBeMapped = new Map<Id,Boolean>();
        List<Opportunity> OppList = new List<Opportunity>();
        List<Account> accList = new List<Account>();
        
        for(Opportunity Opp: newList){

            if(OldMap!=null && Opp.StageName =='Clossed Won'!= oldMap.get(Opp.Id).StageName =='Closed Won'){   
            }
        }
         
        for(Account Acctt : [SELECT Id, Opportunity_Checkedbox__c  FROM Account Where Id In :ids]){
            
            Account acc = new Account();
            if(OppToBeMapped.Containskey(acc.id)){
                Acctt.Opportunity_Checkedbox__c = true;
                accList.add(Acctt);
            
            }
            if(accList.size()>0)
            update accList;
        }
            
   }
}

Hi All, 
Here  i trying to write a trigger  when opportunity stage will Closed won...one custom field name Opportunity_Checkedbox__c in account should active. 

it's showing error 

In Line 12 - Comparison arguments must be compatible types: Boolean, String

.....Trigger.....

trigger OpportunityAccTrigger on Opportunity (after Update) {
    
    if(Trigger.isAfter && Trigger.isUpdate){
        OpportunityAccTriggerHandler.afterUpdate(Trigger.new, Trigger.OldMap);
    }

}

...........Trigger Handler......for after update

public class OpportunityAccTriggerHandler {
    
   
    public static Void afterUpdate(List<Opportunity> newList, Map<Id,Opportunity> OldMap){
        set<ID> ids = new Set<ID> ();
        Map<Id,Boolean> OppToBeMapped = new Map<Id,Boolean>();
        List<Opportunity> OppList = new List<Opportunity>();
        List<Account> accList = new List<Account>();
        
        for(Opportunity Opp: newList){

            if(OldMap!=null && Opp.StageName =='Clossed Won'!= oldMap.get(Opp.Id).StageName =='Closed Won'){   
            }
        }
         
        for(Account Acctt : [SELECT Id, Opportunity_Checkedbox__c  FROM Account Where Id In :ids]){
            
            Account acc = new Account();
            if(OppToBeMapped.Containskey(acc.id)){
                Acctt.Opportunity_Checkedbox__c = true;
                accList.add(Acctt);
            
            }
            if(accList.size()>0)
            update accList;
        }
            
   }
}

I am trying to build a trigger that is triggered once a status is changed from a field on an custom object, it should update a chosen field from a related list of that custom object. However, I keep on receving this error. Does anyone know what this means or how I can fix it?