• Patrick/ James
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies
Hi there,

I have a flow (built with the Process Builder) that is triggered from the first Event of a recurring series. I'm having problems because the system is treating the 'series' record and the 'event' record as two seperate records, so the flow is triggered twice.

Is there any sort of checkbox formula I can create, that can easily mark whether the record is a series record or a one-off event record? At first it looks as the the - DATEVALUE(StartDateTime) - on the series record is one day less than the 1st event of the series, but this isn't consistent across all of our recurring events.

Many thanks.
Hi there,

I'm quite new to Apex Triggers, so just trying to find my feet here.

On the Campaign object we have a lookup to a custom object called 'Course Templates'. We also have a lookup on the Campaign object to another custom object called 'Course Archives'.

All of the 'Course Template' records have duplicates 'Course Archive' records. So - for example - the Course Template record 'Acting - Beginners' has a Course Archive equivalent (also called 'Acting - Beginners').

The trigger below is intended to populate the Course Archive lookup on the Campaign, using the name of the Course Template. The error I'm receiving seems to suggest that I actually need the ID of the record in order to input into this lookup field, but I only have the name of the record.
 
trigger CourseArchiveInclusion on Campaign (before insert, before update) { 
    for (Campaign c : Trigger.new) {
        if(c.status != null && (c.Status.equals('Completed') ||  c.Status.equals('Cancelled'))){
            c.course_archive__c = c.Template_Name_for_Archive__c;
        }
    }
}

Is there a workaround for this?

Many thanks.
 
Hi there,

I'm quite new to Apex Triggers, so just trying to find my feet here.

On the Campaign object we have a lookup to a custom object called 'Course Templates'. We also have a lookup on the Campaign object to another custom object called 'Course Archives'.

All of the 'Course Template' records have duplicates 'Course Archive' records. So - for example - the Course Template record 'Acting - Beginners' has a Course Archive equivalent (also called 'Acting - Beginners').

The trigger below is intended to populate the Course Archive lookup on the Campaign, using the name of the Course Template. The error I'm receiving seems to suggest that I actually need the ID of the record in order to input into this lookup field, but I only have the name of the record.

Is there a workaround for this?

Many thanks.
 
trigger CourseArchiveInclusion on Campaign (before insert, before update) { 
    for (Campaign c : Trigger.new) {
        if(c.status != null && (c.Status.equals('Completed') ||  c.Status.equals('Cancelled'))){
            c.course_archive__c = c.Template_Name_for_Archive__c;
        }
    }
}
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: Trigger.new){
   camIdSet.add(camm.CampaignId);
 }
 Map<Id,Campaign> camMap=new Map<Id,Campaign>([SELECT Id,Extra_Info_for_Reminder__c FROM Campaign WHERE Id IN :camIdSet]);
 for(CampaignMember campMem: Trigger.new){
   if(campMem.CampaignId != null ){
     campMem.Course_Email_Info_2__c=camMap.get(campMem.CampaignId).Extra_Info_for_Reminder__c;
   }
 }
}

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 (
Extra_Info_for_Reminder__c).

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,

Patrick

 
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​

 
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:

User-added image

If anyone is able to offer a simple solution that would be much appreciated.

Thanks very much.
Hi there,

I'm very new to Apex Triggers, so apologies if this is a silly question...

I'm trying to get a Rich Text field on my Campaign object - Extra_Info_for_Reminder__c - to populate a Rich Text field on my Campaign Member object - Course_Email_Info_2__c​. As far as I understand, copying the fields via a workflow strips the text of any HTML (which we need to retain).

In Developer Console the following code doesn't show up with any errors, but it not currently providing the desired affect...
 
trigger richtextupdate on Campaign (after update, after insert) {

for(Campaign C:trigger.new){
    if(C.Extra_Info_for_Reminder__c!=null){
CampaignMember.Course_Email_Info_2__c=C.Extra_Info_for_Reminder__c;
}
}
}

Hopefully there's a very simple explaination. As I say, bit of a fish out of water with this stuff, so any help is much appreciated.

Thanks very much.
Hi there,

I'm quite new to Apex Triggers, so just trying to find my feet here.

On the Campaign object we have a lookup to a custom object called 'Course Templates'. We also have a lookup on the Campaign object to another custom object called 'Course Archives'.

All of the 'Course Template' records have duplicates 'Course Archive' records. So - for example - the Course Template record 'Acting - Beginners' has a Course Archive equivalent (also called 'Acting - Beginners').

The trigger below is intended to populate the Course Archive lookup on the Campaign, using the name of the Course Template. The error I'm receiving seems to suggest that I actually need the ID of the record in order to input into this lookup field, but I only have the name of the record.
 
trigger CourseArchiveInclusion on Campaign (before insert, before update) { 
    for (Campaign c : Trigger.new) {
        if(c.status != null && (c.Status.equals('Completed') ||  c.Status.equals('Cancelled'))){
            c.course_archive__c = c.Template_Name_for_Archive__c;
        }
    }
}

Is there a workaround for this?

Many thanks.
 
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​

 
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:

User-added image

If anyone is able to offer a simple solution that would be much appreciated.

Thanks very much.
Hi there,

I'm very new to Apex Triggers, so apologies if this is a silly question...

I'm trying to get a Rich Text field on my Campaign object - Extra_Info_for_Reminder__c - to populate a Rich Text field on my Campaign Member object - Course_Email_Info_2__c​. As far as I understand, copying the fields via a workflow strips the text of any HTML (which we need to retain).

In Developer Console the following code doesn't show up with any errors, but it not currently providing the desired affect...
 
trigger richtextupdate on Campaign (after update, after insert) {

for(Campaign C:trigger.new){
    if(C.Extra_Info_for_Reminder__c!=null){
CampaignMember.Course_Email_Info_2__c=C.Extra_Info_for_Reminder__c;
}
}
}

Hopefully there's a very simple explaination. As I say, bit of a fish out of water with this stuff, so any help is much appreciated.

Thanks very much.