[SalesForce] How to successfully Deploy a Configuration Component for a Platform-Event Trigger to Override the Automated Process User

I am trying to override the Automated Process user with another user for a platform event.

This Salesforce documentation covers it:

Configure the User and Batch Size for Your Platform Event Trigger

PlatformEventSubscriberConfig

In accordance with the second article, I'm trying to accomplish my goal by deploying a component containing configurations for my platform-event trigger (and I'm in API version 51.0), but every attempt I've made to deploy has failed.

Depending on how I go about it, either I achieve a successful deployment of 0 components, or it fails at the deployment of the one component.

In the latter case, this is the error message:

An object 'RemoteTrxAcceptanceTriggerConfig' of type PlatformEventSubscriberConfig was named in package.xml, but was not found in zipped directory.

I've tried both with workbench and sfdx. I have a directory and a zip file like below in my sfdx project:

enter image description here

Besides workbench, I tried these commands:

sfdx force:mdapi:deploy -f metadata.zip -w -1

sfdx force:mdapi:deploy -d metadata -w -1

In all those attempts, the error is as I've shown above.

These are the files:

RemoteTrxAcceptanceTriggerConfig

<?xml version="1.0" encoding="UTF-8"?>
<PlatformEventSubscriberConfig xmlns="http://soap.sforce.com/2006/04/metadata">
    <platformEventConsumer>RemoteTrxAcceptanceTrigger</platformEventConsumer>
    <batchSize>2000</batchSize>
    <masterLabel>RemoteTrxAcceptanceTriggerConfig</masterLabel>
    <user><USERNAME></user>
    <isProtected>false</isProtected>
</PlatformEventSubscriberConfig>

package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <name>PlatformEventSubscriberConfig</name>
        <members>RemoteTrxAcceptanceTriggerConfig</members>
    </types>
    <version>51.0</version>
</Package>

If I try with a wildcard in the members tag of package.xml, I get a successful deployment of 0 components.

I've tried no file extension for RemoteTrxAcceptanceTriggerConfig as well as:

  • .xml
  • .component
  • .xml-meta.xml

I also tried accompanying RemoteTrxAcceptanceTriggerConfig with a separate RemoteTrxAcceptanceTriggerConfig.xml-meta.xml file, but I could only guess at what a correct one would look like, if at all applicable.

Best Answer

The below folder structure and file extensions worked for me

enter image description here

Notice I have prefixed the file with the name .platformEventSubscriberConfig

I used the command below

sfdx force:mdapi:deploy -d ./src --wait=-1 --json

Notice I don't have to deal with the zip files in this command. I am providing the directory relative path. In this case, it is src The CLI automatically takes care of it!

Since it's new metadata in v51.0 the source:retrieve and source:deploy commands may not be supported