function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joe Andolina 7Joe Andolina 7 

SFDX Retrieve Platform Event Metadata

How can I pull a platform event into my VSCode project using SFDX? I am looking for the equivalant call to the flow retrieve below:
sfdx force:source:retrieve -m Flow:TestFlow -u user@idomain.demo

I have tried 
sfdx force:source:retrieve -m Platform:TestPE -u user@idomain.demo

sfdx force:source:retrieve -m PlatformEvent:TestPE -u user@idomain.demo

No luck...
Best Answer chosen by Joe Andolina 7
AnudeepAnudeep (Salesforce Developers) 
Hi Joe - I don't think there is an sfdx command to pull the PlatformEvent Metadata directly. You should use the package.xml Manifest file to retrieve this Metadata. See this documentation to learn more

Let me know if this helps

Thanks, 
Anudeep
 

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Joe - I don't think there is an sfdx command to pull the PlatformEvent Metadata directly. You should use the package.xml Manifest file to retrieve this Metadata. See this documentation to learn more

Let me know if this helps

Thanks, 
Anudeep
 
This was selected as the best answer
Joe Andolina 7Joe Andolina 7
Thank you for the reply. You are right, I had to use a manifest (package.xml) to get what I was looking for. Turns out the Platform Events are actually Custom Objects. Notice the __c and __e in the manifest.
<types>
   <members>MY_CUSTOM_OBJECT__c</members>
   <name>CustomObject</name>
</types>
<types>
   <members>MY_PLATFORM_EVENT__e</members>
   <name>CustomObject</name>
</types>

 
AnudeepAnudeep (Salesforce Developers) 
Hi Joe, 

Thanks for the reply. If you find the information I shared above helpful and to close loop this, Please mark this answer as Best. It may help others in the community

Thanks, 
Anudeep

 
Shane BirdShane Bird
It is possible to retrieve PlatformEvent metadata from an org using sfdx:
sfdx force:source:retrieve -m "CustomObject: PlatformEventName__e" -u "targetOrgUsername@mail.com"
As you mentioned platform events are stored in the objects folder and folowing this logic the above command will owrk fine.
 
Prajakta Solanki 6Prajakta Solanki 6
Platform events, Custom Settings and Custom Metadata all are under Objects. Example platform_eventname__e, customsettings__c and customMetadata__mdt