11

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.

1
  • what command did you try in SFDX? Commented Feb 6, 2021 at 22:58

3 Answers 3

9

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

2
  • The documentation indicates the ability to deploy it, but maybe it's not ready yet since v51.0 is brand new. I tried your suggestion. It technically executes successfully, but deploys 0 components. Commented Feb 6, 2021 at 23:51
  • 1
    If you are on Spring 21 orgs, it did work fine for me! I can see in logs it went fine! Did you have the folder structure properly created as shown in the screenshot? Commented Feb 6, 2021 at 23:56
11

This feature seems extremely finicky. I noticed that the XML metadata API deployment was NOT correctly populating the data (You can verify with the SOQL query below.) I managed to get it working relatively consistently with the following steps:

  • Log in to Workbench -> REST Explorer
  • Use the following POST endpoint: /services/data/v51.0/tooling/sobjects/PlatformEventSubscriberConfig (See below if you get Duplicate ID error)
  • JSON body should look like the following, replace names w/ desired names (doesn't need to correspond to any particular object or event name):
{
    "BatchSize": "2000",
    "DeveloperName":"YourNameTriggerConfig",
    "MasterLabel":"YourNameTriggerConfig",
    "PlatformEventConsumerId": "01qXXXXXXXXX",  <-- Apex Trigger ID
    "UserId": "005XXXXXXXXXX"  <-- Desired User ID
}
  • Then give it about 10 minutes. Changes don't seem to apply immediately. May take longer if SF servers are under heavy load.

  • If you get a Duplicate Id error, see Note 2 below, you can use that query to manually delete these in your environment.

Note 1, if you do this in production, this configuration WILL flow down to Sandboxes and correctly update the User Id and Trigger Id automatically.

Note 2, you can query your PlatformEventSubscriberConfig in the dev console to make sure it is all configured correctly (or delete it if you get the Duplicate ID error in Workbench)

Select id, MasterLabel, UserId, PlatformEventConsumerId FROM PlatformEventSubscriberConfig

2
  • 1
    adding my observations: - It's possible to update records with a PATCH call to /services/data/v52.0/tooling/sobjects/PlatformEventSubscriberConfig/{ID} also, as of Summer 21 v52: - works only with apex triggers. We can't change batch size of Platform event Flows. - PlatformEventSubscriberConfig doesn't affect test methods - during test run all platform events will be processed in one transaction independent of BatchSize set in the org. Commented Jul 9, 2021 at 18:19
  • 2
    In order to get the PlatformEventSubscriberConfig to take effect, I found that I had to suspend the trigger's subscription (Setup | Develop | Platform Events | [Event Name] | Manage), then resume it.
    – xn.
    Commented Nov 25, 2021 at 0:51
0

When working with the metadata source:

Folder Name: PlatformEventSubscriberConfigs

(Case-sensitive and don't forget the capital 'P' at the beginning and lowercase 's' at the end) This deviates from the usual folder naming-conventions for the other metadata types.

Metadata Format Filename: MyEventConfig.platformEventSubscriberConfig

Source Format FileName: MyEventConfig.platformEventSubscriberConfig-meta.xml

Package.xml

<types>
    <members>MyEventConfig</members>
    <name>PlatformEventSubscriberConfig</name>
</types>

You must log in to answer this question.

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