+ Start a Discussion

How do I show the campaign name in the opportunity Record

How do I show the campaign name in the opportunity record under lead information fields, Other fields that I wanted I mapped them and they are visible

Here, I want the campaign name to be in the lead information section on the opportunity page when the lead is converted

Any suggestions here

So far These are the steps done

Step 1: Create a custom field on the lead --> Campaign_Name__c
Step 2: Create an Apex class to populate this^ field with Campaign Name
public class  CampmemTriggerhelper{

public static void CampmemTrigger(list<CampaignMember> lstcmp){

          set<Id> leadIds=new set<Id>();
       list<Lead> lstleads=new list<Lead>();
       map<Id,string> mapLeadIdByCampaign=new map<Id,string>();

       for(CampaignMember c:[Select Id,LeadId,Campaign.Name from  CampaignMember where ID IN:lstcmp]){

       for(Lead l:[Select Id,Campaign_Name__c from Lead where Id in :leadIds]){

         update lstleads;


Step 3: Create an Apex Trigger on Campaigns to call that^ class
trigger CampmemTrigger on CampaignMember(after insert){


Step 4: Now that you have the Campaign Name field on Lead populating Campaign Name, use this field to map the field on Opportunity.

I am not sure of which object should we have the trigger on? and if the value is on the field I can map it to newly created field on opportunity but where should the trigger be
SFDC Prime SquadSFDC Prime Squad
So ideally, you want to populate Campain details on the Opportunity detail page. This should happen as soon as the lead is getting converted and a new opportunity getting created.

If this is the case, then you can write a trigger on Opportunity, query the details from Lead-->Campaign and write it back on opportunity.