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
MySetMySet 

Trigger concept

Hi,

 

Suppose I want to see all the fields of a particular record of an Account through Trigger.new or Trigger.old, how can we see that in debug log?

Trigger triggerName on Account(before insert, before update){
  for(Account a : Trigger.new){
     System.debug('I want to see all fields of a record'+ WHAT_NEED_TO_BE_ADDED)
  }

 

Dhaval PanchalDhaval Panchal
You can see field wise below.

System.debug('I want to see all fields of a record'+a.name);
System.debug('I want to see all fields of a record'+a.Id);
......
and so on.

but you need to write all fields.

Instead better to use below.

System.debug('I want to see all fields of a record: '+ a);
MySetMySet

Ohhh....so I can't get all field values on a single go.

 

Thanks for replying.

 

crop1645crop1645

Assuming this is really important to you, you could do the following

 

1. Requery the triggered SObject(s) in the trigger using Dynamic SOQL where you construct the fields in the SOQL by going to the SchemaDescribe class

2. Then, if you use system.debug on the queried object(s), you'll get all the fields

 

A better strategy is to write a utility class that displays the important fields to you and that you can invoke from many places