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
Patrick/ JamesPatrick/ James 

Test classes - Rich Text Fields - Cross-object

Hi there,

It's worth stating that I'm extremely new to APEX trigger writing - so apologies for the inexperience.

We've written the following trigger in Sandbox -
trigger RichText1 on CampaignMember (before insert, before update) {
Set<Id> camIdSet=new Set<Id>();
  for(CampaignMember camm:{
 Map<Id,Campaign> camMap=new Map<Id,Campaign>([SELECT Id,Extra_Info_for_Reminder__c FROM Campaign WHERE Id IN :camIdSet]);
 for(CampaignMember campMem:{
   if(campMem.CampaignId != null ){

When a Campaign Member record is created/updated, this trigger populates a Rich Text field on the Campaign Member record (
Course_Email_Info_2__c) with the data contained within a Rich Text field that exists on the corresponding Campaign record (

We're looking to move this trigger to Production, but I'm struggling to work out where to start when it comes to APEX Test Classes. I've looking for a comprehensive easy-to-follow tutorial, but can't find much.

Would anyone be able to suggest a simple APEX Test Class for this trigger?

Many thanks in advance,


Shyama B SShyama B S
Go through this link Apex Testing ( The tutorial is really good and hardly takes an hour. You will be able to write the test class yourself :) Please let me know if you need any help.