1

I'm trying to create an unlocked package that uses an Apex trigger to create campaign influence records for a custom campaign influence model. I keep running into errors that seem to be caused by the Apex trigger that creates the campaign influence records.

I used a playground org to develop the Apex trigger as well as the other components for the package (Apex test class, custom campaign influence model record, permission sets...). I tried to add the trigger to an unmanaged package so I could retrieve it with sfdx, but the trigger was not visible when I was trying to add it as a package component. I could add everything else to the package, including the test class for the trigger.

I was able to retrieve the Apex trigger separately without adding it to the package, but now when I try to create the first unlocked package version with sfdx, I'm getting this error:

"Multi_Touch_Campaign_Model: Not available for deploy for this organization, CampaignInfluenceRecordCreationTest: Invalid type: CampaignInfluence,.."

My playground org has dev hub, unlocked packages, and campaign influence enabled. My apex api version is 48. I'm relatively new to developing in SF, but I can't find any similar scenario online.

I guess I should add that the Apex trigger works fine along with the other components I developed for this package in the trailhead playground.

1

You need to include the appropriate settings file in order for this to work in an Unlocked Package.

The CampaignInfluenceModel metadata is supported in Unlocked Packages. You will need to include a Settings file in your Unlocked Package in order to "enable" this for your package, as it is not enabled by default in any org.

Enabling this will also require orgs where the package is to be installed to have this feature enabled before installing the package.

0

I'm actually op, but I can't log in with guest account to mark as solved for some reason.

But sfdcfox's answer worked!

To be more specific, I had to add a definitionfile reference to the sfdx project json file that points to my scratch org config json file. In the scratch org file, I added a campaign setting: "enableCampaignInfluence2": true.

0

I encountered another problem trying to create another package version. I'm trying to add custom reports based on the standard "Campaigns with Influenced Opportunities (Customizable Campaign Influence) report type, but I'm getting this error:

ERROR running force:package:version:create: MultiTouchCampaignAttributionReports/Campaigns_Responses_Timeline_32e: ReportType: CustomizableCampaignInfluence is not available,CampaignDashboards/LVifBmlFPZfCzLyPdtRuoaDwcPJgdR: In field: report - no Report named MultiTouchCampaignAttributionReports/Campaigns_Responses_Timeline_32e found,MultiTouchCampaignAttributionReports/Campaigns_with_Influenced_Opportunities_2Pg: ReportType: CustomizableCampaignInfluence is not available

This is a standard report type that i think gets generated when an org enables customizable campaign influence, but I already have that setting in my definition file. Is there another setting I need to add, or is there no way to deploy reports based on this report type?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.