• John Aaron Nelson
  • NEWBIE
  • 10 Points
  • Member since 2015
  • Code Scientist
  • CodeScience


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I have written a trigger.that logic is working fine for me . when i inserting a new record ,the trigger is not firing.but updating a same record trigger is working fine.the trigger logic is the discount is exceeded morethan fixed discount the checkbox 'Granted discount KO' is checked.i have tried tigger.isinsert and trigger.isnew context variables but same result.can you anybody help me.
Trigger:
trigger Rfleet_validDiscountpercent on Opportunity_car_set__c (before insert,before update) {
    decimal d;
    set<id>oppids=new set<id>();
    string conca;
    list<Opportunity> lsupdateopp=new list<Opportunity>();

        for(Opportunity_car_set__c oppcarset:[select Model__r.Name, Discount__c,Opportunity__r.Total_Fleet_Size__c,Model__c,Rfleet_Country_Code__c,CreatedDate from Opportunity_car_set__c  where id in:trigger.new]){
            integer dt=oppcarset.CreatedDate.Year();
            conca = oppcarset.Model__r.Name +oppcarset.Rfleet_Country_Code__c + string.valueof(oppcarset.Opportunity__r.Total_Fleet_Size__c)+string.valueof(dt);
            system.debug('conca----->'+conca);
       
        }
     
     list<Discount_Grid__c> listDisGrid=[select Rfleet_Status__c,Rfleet_Discountconca__c,Rfleet_Discount__c from Discount_Grid__c  where Rfleet_Status__c = 'Enabled' and Rfleet_Discountconca__c=:conca order by CreatedDate desc limit 1];
     system.debug('>>>>>>>>>>>>>>:'+listDisGrid);
       for(Opportunity_car_set__c opp:trigger.new){
            for(Discount_Grid__c disGrid:listDisGrid){
               if(opp.Discount__c >disGrid.Rfleet_Discount__c){
                    opp.Rfleet_Granted_discount_KO__c = true;
                    oppids.add(opp.Opportunity__c);
                }else{
                      oppids.add(opp.Opportunity__c);
                }
            } 
      }
    
     list<Opportunity>opplistupdate=[select Rfleet_Granted_discount_KO__c from Opportunity where id=:oppids];
       system.debug('>>>>>>>>>>>>>>:'+opplistupdate); 
       
        
         for(Opportunity_car_set__c oppCar:trigger.new){
         
             for(Opportunity updateopp:opplistupdate){
                    if(oppCar.Rfleet_Granted_discount_KO__c==true && opplistupdate.size()>0){
                         updateopp.Rfleet_Granted_discount_KO__c =true;
                         lsupdateopp.add(updateopp);
                     }else if(oppCar.Rfleet_Granted_discount_KO__c==false && opplistupdate.size()>0){
                         updateopp.Rfleet_Granted_discount_KO__c =false;
                         lsupdateopp.add(updateopp);
                     }
             }
             update lsupdateopp;
        }
        
        
}
I'm writing an IDE plugin and I prefer using the REST API.  For the Execute Anonymous resource:

http://domain/services/data/vXX.X/tooling/executeAnonymous/?anonymousBody=System.debug('Hello World');

The response is:

{"exceptionMessage":null,"compileProblem":null,"compiled":true,"exceptionStackTrace":null,"column":-1,"line":-1,"success":true}

How do I get access to the output/debug log?