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
Naitik RaiNaitik Rai 

Workflow or Process Builder to change Campaign Member Field same as Lead Field

Hello Friends,

Anyone help me on this issue.
I have a picklist field on a Lead named "Progress Status".
 
Field Name : Progress Status
Values : Success, Under Phase, Overturned

When this field changes it should update the Field "campProgres Status" on the same Campaign Member. 
For e.g on the lead XYZ's field Progress Status = Success.  I would like the field 'campProgres Status' on the campaign member equal to Success, i.e campProgres Status = Success

Any help with the Process Builder or Workflow rule would be greatly appreciated.
v varaprasadv varaprasad
Hi Rai,

1. To achieve your functionality Using Process Builder  check once below link : 
https://automationchampion.com/2015/03/04/getting-started-with-process-builder-part-6-working-with-related-records/

2. To achieve through trigger : 
 
Trigger updteStatusOnCampaignMembers on lead(after insert,after updte){
  
   
   Map<id,lead> leadIds = new map<id,lead>();
   for(lead l : trigger.new){
        if(l.Progress_Status__c != null){
	      leadIds.put(l.id,l);
     }  
   
   }
   
    List<CampaignMember> updlstOfcam = new List<CampaignMember>();
   List<CampaignMember> lstOfcam = [SELECT Id,Leadid,campProgres_Status__c FROM CampaignMember where Leadid in : leadIds.keyset()];
   
   if(lstOfcam.size() > 0){
      for(CampaignMember cm : lstOfcam){
	       cm.campProgres_Status__c = leadIds.get(cm.Leadid).Progress_Status__c;
	       updlstOfcam.add(cm);
	  }
   
   
   }
  
   if(updlstOfcam.size() >0){
      update updlstOfcam;
   }


}

Hope it helps you.
If the above information is informative Please mark it as the best answer.


Thanks
Varaprasad