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

New test class

Hi everyone-  I posted a question last week regarding a test class but unfortunately I was never able to figure out an answer.  I need to write a test class for the following trigger:


trigger ReportsToDefensive on Defensive_Tracking__c (before insert, before update) {
	//Pull reports_to__c from user record
       // create a set of all the unique ownerIds

  Set<Id> ownerIds = new Set<Id>(); for (Defensive_Tracking__c d : ownerIds.add(d.Account_Owner__c); // query for all the User records for the unique userIds in the records // create a map for a lookup / hash table for the user info
 Map<Id, User> owners = new Map<Id, User>([Select USER.Reports_To__c from User Where Id
in:ownerIds]); // iterate over the list of records being processed in the trigger and // set the field values before insert & update

 for (Defensive_Tracking__c d: { d.Reports_To__c = owners.get(d.Account_Owner__c).Reports_To__c; } }

Can somebody please help me take a stab at it?  I'd greatly appreciate it.