You need to sign in to do that
Don't have an account?

Trigger Issue - Rich Text Fields - Cross-object
Hi there,
I'm very new to Apex Triggers, so apologies I'm being a bit stupid here.
We have the following code to populate a Rich Text field on a Campaign Member with the contents of a Rich Text field on the corresponding Campaign (we obviously need to preserve the formatting).
Campaign Member RT field: Course_Email_Info_2__c
Campaign RT field: Extra_Info_for_Reminder__c
Unfortunately - the following error is appearing when we try and edit a Campaign record:

If anyone is able to offer a simple solution that would be much appreciated.
Thanks very much.
I'm very new to Apex Triggers, so apologies I'm being a bit stupid here.
We have the following code to populate a Rich Text field on a Campaign Member with the contents of a Rich Text field on the corresponding Campaign (we obviously need to preserve the formatting).
Campaign Member RT field: Course_Email_Info_2__c
Campaign RT field: Extra_Info_for_Reminder__c
trigger RichText1 on Campaign (after insert, after update) { List<CampaignMember> memberList=new List<CampaignMember>(); Map<Id,Campaign> CampMemMap=new Map<Id,Campaign>([select id, (select id from CampaignMembers) from Campaign where id IN: Trigger.new]); for(Campaign c: Trigger.new){ if(c.Extra_Info_for_Reminder__c!=null && CampMemMap.get(c.id).CampaignMembers.size()>0){ memberList.addAll(CampMemMap.get(c.id).CampaignMembers); for(CampaignMember m: memberList){ m.Course_Email_Info_2__c=c.Extra_Info_for_Reminder__c; } } } if(memberList.size()>0){ update memberList; } }
Unfortunately - the following error is appearing when we try and edit a Campaign record:
If anyone is able to offer a simple solution that would be much appreciated.
Thanks very much.
Thank you very much for your reply.
I had to tweak your code slightly (at the end it should be "(campMem.CampaignId)") but it works-
Might there be an option of the Trigger being in Campaign not CampaignMember? In some instances we would like to save the one Campaign record, not have to update each Campaign Member record.
Thanks again!
All Answers
Basically here the trigger should in campaignMember not in campaign .
Please try with belwo code and let me know if it helps .
Let me know if it helps !!
Thanks
Manoj
Thank you very much for your reply.
I had to tweak your code slightly (at the end it should be "(campMem.CampaignId)") but it works-
Might there be an option of the Trigger being in Campaign not CampaignMember? In some instances we would like to save the one Campaign record, not have to update each Campaign Member record.
Thanks again!
I got your query you want some thing like if you will update campaign then related CampaignMember should update the same .
Then your event will only on update .
Try with below it will work !! How ever if you will insert any new campainMember after update of your Campaign above code wil not update for that .For that you need to write a trigger in CampaignMember before insert ,inthis case you use the above Campaignmember trigger .
Let me know if it helps !!
Thanks
Manoj