You need to sign in to do that
Don't have an account?
Formula field on Campaign Member object
Hi Folks,
I have a custom field (Score) on both my contact and lead objects that I want to includein campaign member reports. Since the report interface does not allow me include custom fields, I need to create a custom formula field (let's call it CMScore) on the Camapign Member object that pulls this data from the lead/ contact field. Can someone explain to me what syntax to use for the formula- i'm a newbee and nto familiar with using formulae.
This is essentially what it needs to do:
CMScore=
Lead.Score if CampaignMember is a Lead
Contact.Score if CamapignMember is a Contact
Any help is greatly appreciated!
Thanks!
@ashishkr is correct:
The one drawback to this approach is that it counts twice toward the unique relationships per object limit.
All Answers
You will need to use a trigger for this, since the CampaignMember object only has the ID of the Contact/Lead, not the related record. The easiest trigger would be to create 2 Lookup fields on the CampaignMember, 1 called RelatedContact, the other called RelatedLead. The trigger will just set the ContactID into the RelatedContact field, and LeadID to the RelatedLead field. Then, you'll have related records on the Campaign Member object and you can write a formula like the following:
RelatedContact__r.Score__c
You can use cross-object formula for this:
if( NOT( ISBLANK( ContactId ) ), Contact.Email , Lead.Email )
Make sure you select treat blank field as blank while creating this formula.
This formula has the reasonable assumption that a CampaignMember will either be a Lead or a Contact.
Instead of the Email, you can use your custom score field as Contact.Score__c.
@ashishkr is correct:
The one drawback to this approach is that it counts twice toward the unique relationships per object limit.
Thank you all for your responses! I was able to create the field and get my report working. This is my first time using the discussion boards and it has been a great experience. I'm sure I'll be posting more questions soon!:)
Glad we could help! Please be sure to "Accept as Solution" the answer that helped you, so that others can see that the question was resolved and may benefit. It's also nice to give kudos if someone really helped you out.
I've played with the formula Shannon provided but can't seem to figure it out. Any help?
this condtion is also working .
text(Lead.picklistvalue)<>text(Contact.picklistvalue)
thanks
VIswa
This is what I am using:
if( NOT( ISBLANK( Email ) ), Text (Contact.Hubspot_Lead_Score__c) , Text (Lead.Hubspot_Lead_Score__c )) - this pulls the info from the contact but not the lead - or-
if( NOT( ISBLANK( Email ) ), Text (Lead.Hubspot_Lead_Score__c) , Text (Contact.Hubspot_Lead_Score__c )) - this pulls it from the lead but not the contact
Thank you!