fork download
  1. public class CampaignTriggerHandler{
  2.  
  3. public static void updateOpportunityStatus(Set<Id> campaignIds){
  4.  
  5. List<Opportunity> oppListUpdated = new List<Opportunity>();
  6.  
  7. List<Opportunity> oppHasLineItemsWithCampaigns = [Select Id,CampaignId,Status,
  8. (Select Id FROM OpportunityLineItems)
  9. FROM Opportunity
  10. WHERE CampaignId IN: campaignIds]; // opportunity with associated campaign and has line items
  11.  
  12. for(Opportunity opp: oppHasLineItemsWithCampaigns)
  13. {
  14. if(!oppWithCampaigns.isEmpty() && opp.OpportunityLineItems != 0){
  15. opp.Status = 'Closed Won';
  16. oppListUpdated.add(opp);
  17. }
  18. else{
  19. opp.Status = 'Closed Lost';
  20. oppListUpdated.add(opp);
  21. }
  22. }
  23. if(!oppListUpdated.isEmpty()){
  24. update oppListUpdated;
  25. }
  26.  
  27. }
  28. }
Success #stdin #stdout #stderr 0.02s 12092KB
stdin
Standard input is empty
stdout
Object: UndefinedObject error: did not understand #CampaignTriggerHandler
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #CampaignTriggerHandler (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
Object: nil error: did not understand #associationAt:ifAbsent:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #associationAt:ifAbsent: (SysExcept.st:1448)
DeferredVariableBinding>>resolvePathFrom: (DeferBinding.st:115)
DeferredVariableBinding>>value (DeferBinding.st:69)
UndefinedObject>>executeStatements (prog:14)
Object: nil error: did not understand #associationAt:ifAbsent:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #associationAt:ifAbsent: (SysExcept.st:1448)
DeferredVariableBinding>>resolvePathFrom: (DeferBinding.st:115)
DeferredVariableBinding>>value (DeferBinding.st:69)
UndefinedObject>>executeStatements (prog:23)
stderr
./prog:3: parse error, expected '}'
./prog:14: expected expression
./prog:14: expected expression
./prog:23: expected expression