[SalesForce] INVALID_FIELD error when adding a custom lookup field onto the Campaign History related list in lightning

The Campaign History related list is broken on the lead and contact when using the lightning experience if you have a custom lookup field on the related list.

When you load the contact or lead, the related list shows an error similar to:

INVALID_FIELD: (SELECT Campaign.Id, Campaign.Name, Campaign.Opportunity__c, Campaign.StartDate ^ ERROR at Row:1:Column:54 No such column 'Opportunity__c' on entity 'Campaign'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

This issue appears to be happening for managed package custom lookup fields as well.

Update: This is currently still an issue on Summer '17 sandboxes, though instead of showing an error message the lightning spinner just spins endlessly.

Best Answer

It seems as though the Campaign History related list is trying to query for the custom lookup field on the Campaign object instead of the Campaign Member object.

I'm fairly certain this is a Salesforce bug and not related to any custom code, as the Campaign History related list is maintained by Salesforce and I have reproduced this in a pretty empty dev org. I've opened Case #15890319 and am waiting to hear back from Salesforce on this. (Update: It's fixed!)

I will update this answer to the Known Issue if/when it gets created. I just wanted to post this here in case anybody comes across this issue in the meantime.

Update: I've been told this bug is related to this known issue, though it seems slightly different since the bug only affects custom lookup fields.

Update #2: This is slated to be fixed for the Summer '17 Release, per a comment on the Lightning Now! Success Community.

Update #3: While the known issue linked above is not yet fixed, lookups on the Campaign History related list now seem to no longer break the related list in the Lightning Experience!

Workarounds

There are a few different options that could be done while this is being resolved.

  1. Create a custom formula field that links to the record. Note that this will force anybody to go to lightning, even if they're in classic mode (& if lightning isn't enabled for them, I suppose it would result in some sort of error? I have not tested thoroughly.) IF(!ISBLANK(Custom_Lookup__c),HYPERLINK('/one/one.app?#/sObject/'+ Custom_Lookup__c + '/view',Custom_Lookup__r.Name),'')

  2. Formula fields that span relationships seem to still work. So if you wanted to just display the name of the field, you could create a formula to Custom_Lookup__r.Name and just display that instead, or other fields on the object.

Related Topic