0

Trying to add the Campaign Influence related list to a visualforce page as shown below.

<apex:page standardController="Opportunity" id="opportunityPage" tabStyle="Opportunity">
<apex:detail relatedList="false" relatedListHover="true" title="true"/>

<apex:relatedlist list="OpenActivities" id="activityList" />
<apex:relatedlist list="ActivityHistories" id="activityHistoryList" />

<!-- line below fails with 
''CampaignInfluence' is not a valid child relationship name for entity Opportunity' -->  
<apex:relatedList list="CampaignInfluence" id="campaignsList" />

</apex:page>

Cannot figure out right value for the campaign influence related list value. Does anyone know what this should be? or has been able to get this working?

Thanks!

3 Answers 3

1

I think, you should try this. You are just missing a "s".

<apex:relatedList list="CampaignInfluences" id="campaignsList" />

How did I find it: I ran this query in my developer console and found all child sObjects of Opportunity

List<Schema.ChildRelationship> child = Opportunity.sObjectType.getDescribe().getChildRelationships();

Then, I looped over the results to find child side API name of CampaignInfluence sObject.

3
  • Thanks! Tried this but still get the error.. <apex:page standardController="Opportunity" id="opportunityPage" tabStyle="Opportunity"> <apex:detail relatedList="false" relatedListHover="true" title="true"/> <apex:relatedList list="CampaignInfluences" id="campaignsList" /> </apex:page> Commented Apr 8, 2018 at 8:41
  • 'CampaignInfluences' is not a valid child relationship name for entity Opportunity Commented Apr 8, 2018 at 8:44
  • 1
    Well, it works fine when I use it in SOQL. Let me try your code in my org Commented Apr 8, 2018 at 9:46
1

The problem may be the API version you are using as CampaignInfluence:

Represents the association between a campaign and an opportunity in Customizable Campaign Influence. This object is available in API version 37.0 and later.

Note This information applies only to Customizable Campaign Influence and not to Campaign Influence 1.0.

So as well as the name as the relationship name that the_phantom mentions, check the API version that the Visualforce is set to.

4
  • Sounds like a plausible answer. Commented Apr 8, 2018 at 18:00
  • Thanks, the visualforce page is using version 42.. I think it has something to do with the way Salesforce internally manages this object which is different and hence causing issues. But no solution. Commented Apr 9, 2018 at 5:16
  • @the_phantom or Keith C were either of you able to get the code working? Thanks!! Commented Apr 10, 2018 at 18:44
  • Starting to think this has something to do with a security setting.. Does anyone know the security required to see the Campaign Influence related list? Strange that it still fails for system administrators but thinking that maybe even that profile doesn't have the required permission for this object.. Commented Apr 12, 2018 at 16:48
0

Try this

<apex:relatedList list="InfluentialCampaigns__r" />

Cf Workbench / Menu Info / Standard & Custom Objects / Opportunity /Child Relationships / CampaignInfluence / relationshipName : InfluentialCampaigns__r

PS : Verify your API version

You must log in to answer this question.

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