Explanation of the error
You may come across this Salesforce validation error when deploying Layout metadata to your target org, or when promoting changes via PR in Pipelines:
"Cannot use field:WhatId in RelatedContent section."
An example of the error may look like this:
This is a known Salesforce issue (referenced here) that affects Task and Event page layout deployments.
As mentioned here, this error can be triggered when your org has any of the following add-ons enabled:
Health Cloud
Financial Services (Lending)
Financial Services (Insurance)
When these add-ons are active, deploying a Task or Event layout that includes WhatId in the relatedContentItems section fails, even if the layout itself hasn't changed.
Resolution
The workaround proposed by Salesforce is to remove the WhatId section from relatedcontentItem.
Deleting this part of XML from the affected Layout metadata should allow you to deploy or promote changes successfully. You can do that by downloading the deployment package and following this article to edit it and compare with a local file.
An example of how the XML looks within Gearset's comparison results preview:
This resolution has worked for other Gearset users.
In terms of longer term solutions, Salesforce mentions these two:
Work with your managed package provide to renew your expired package.
Remove the expired package from the org if it's no longer needed.
If removing the WhatId block doesn't fix it, or if the scenario doesn't match either of the above, reach out in the in-app chat and we'll dig into it with you.
Disclaimer: This error is returned directly by Salesforce, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.


