0

My end goal is to create a custom link on my lead page that will add an extra parameter to the url if the lead is a member of a particular campaign.

I have tried accessing the CampaignMember.CampaignID field as well as the Campaign.Name. Both fields are showing up blank. I assume this is because they aren't actually linked to the Lead.

Is there a way to access the campaigns a Lead is a member of from within a formula field? If so, do I have the capability to loop through them?

Thanks! Greg

1 Answer 1

1

CampaignMember is a junction object between the Lead (or Contact) and the Campaign

As such, you can't write a formula field that traverses through the children of a Lead (i.e. the Lead's CampaignMembers).

Option 1

However, you could try using the Declarative Lookup Rollup Summary (DLRS) package (free) to rollup the Campaign ID from CampaignMember if and only if, the CampaignMember.Campaign.Name = 'Foo'. This is a point and click configuration solution.

Option 2

Write your own trigger on CampaignMember that on afterInsert/Update/Delete/UnDelete updates the parent Lead with the campaign ID, if any, whenever any CampaignStatus.Campaign.Name = 'Foo'

Them, under either option, you now have a custom field on Lead that you can interrogate for your Lead formula field.

Side note: If a Campaign is deleted, all its CampaignMembers are also (cascade) deleted but their trigger won't fire and the Lead record would have an orphan Campaign ID. Dealing with this is an exercise for the reader (one possibility is for your custom Lead field to be a Lookup on Campaign

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .