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
billyweb99billyweb99 

APEX: Debug Log

I have been developing "trigger " code for the first time.

 

I have two questions:

 

Question 1.  I would print out certain aspects of the code as it is executing ... My understanding is that you can use the System.debug statement and look at the Debug Log the information between the single quotes ' Field Print'.  Unfortunately, this is not working for me. 

 

 

 Triigger   Name on  CustomObject__c   (Before Insert) {
           System.debug ('ClientAccountI');
}

 

Question 2.  I would like to print a variable instead of a Field in Quotes.  Do I need to set a vaiable?

 

Example: Trigger Name on CustomObject_c(Before Insert) {

            System.debug (CustomObject__c.variable);

}

   

 

Any help would be appreciated.

Thank you

 
Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

Here are some sample debug statements:

System.debug('******************* About to process sales.... '); //define a variable here integer saleCounter = 0; for (CustomSale__c cSale: SalesToProcess.values()){ System.debug('******************* Current Sale Quantity: ' + cSale.Quantity__c ); //Do stuff with each sale... //... increment the counter saleCounter++; } System.debug('******************* Number of sales processed: ' + saleCounter);

 

Note that you can put any message you want in between single quotes (I use a series of ***'s to make my messages stand out in the debug log).