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
Alan MillerAlan Miller 

Using a formula to display Campaign Member information within the Campaign

Hi all,

I have created a new field within Campaign Members called "Role". A campaign member may have a role of "Author" for instance. What I'm trying to do is display the name of the Campaign Member with that Role within the Campaign page layout. So for instance:

I have a campaign called "Book Discussion" and there are a number of Campaign Members:

Name: Mike Smith
Role: Janitor

Name: Bill Smith
Role: Author

Name: Sandra Smith
Role: Assistant

When I click the Campaign I want to see a field (likely a formula field, read only) showing which of those members has the role of "Author". One of the reasons I want this is because I want to create a view that will show who has the Author "role".

Is there a way to do this? I tried to do this using formulas but I don't have the experience necessary.

Any help would be greatly appreciated.

Thank you,
Alan Miller
Art SmorodinArt Smorodin
Hi Alan, 

I do not think that you will be able to achieve your desired outcome using formulas. The problem is that Campaign and Campaign Members have One-to-Many relationship. Meaning that 1 campaign will have 0, 1 or many members. You would want to update your new Campaign field every time a new member is added.

In my opinion this will have to be a Trigger. This most likely be a After Insert trigger on the Campaign member object. After new member is crated, you will want to grab that member's Role value and append it to the Campaign field. 

I would be curious to see if anyone has a way to achieve the same logic using only formula field(s). 

Alan MillerAlan Miller
Hi Art.

Thank you for your response! I have only created very rudimentary triggers in the past. Can you provide some details on how exactly to accomplish what you have suggested? I would very much appreciate this.

Thanks again,
Doria Hamelryk VetranoDoria Hamelryk Vetrano
Hi Alan,

If you do not want to solve it using apex, you can also set up a visual flow + process builder.
I will try to explain the steps to proceed :

(Visual) Flow
  • Create a variable that will contain the campaign ID, btw : campID
  • Lookup on campaignMember with campaignID=campID and memberRole = "Author"
  • If a record was found :
    • Update the Author field on Campaign object with the campaignMember.Contact
Process Builder 
  • Create a process builder based on creation/modification of the campaignMember object
  • Set up an action of launching flow and pass the campaignID to that flow using the campID var
I don't know if you are you already used Flow to set up such actions, if you need more info, feel free to ask !
Hi Doria,

Thank you so much! I hadn't used the Flow or Process builder yet but based on your instructions I created the flow and attached it to a process and it WORKED! You are a genius, thank you so much!