Apex

Platform Events

Considering you've already gone through Platform Events section of the documentation, this article will walk you through on how to subscribe to thecldfs__CloudFiles_Event__e event, and handle custom logic based on the event type.

If you've set the `CloudFiles Event Mode` setting to custom object, go through this article - Platform Events Apex Handler (Object Type)



Document image




Basic Example:

Apex


Apex Types for different platform event types

Line #21 in the example above displays outputs from the DocumentProcessed event type(i.e. type number 14 in the list below). Depending on your use case, Here are the avilable platform event types and their custom Apex types that you may use to access relevant information:

  1. file-uploaded - FileUpload
  2. file-replaced - FileReplace
  3. salesforce-file-attached - SalesforceFilesAttached
  4. salesforce-file-copied - SalesforceFileCopied
  5. folder-created - FolderCreated
  6. resource-updated - ResourceUpdated
  7. content-version-created - ContentVersionCreated
  8. content-version-created-batch - ContentVersionCreatedBatch
  9. file-received - FileReceived
  10. resource-attached - ResourceAttached
  11. document-generated - DocumentGenerated
  12. resource-cloned - ResourceCloned
  13. file-viewed - FileViewed
  14. document-processed - DocumentProcessed
  15. document-split - DocumentSplit
  16. resource-deleted - ResourceDeleted
  17. error-event - ErrorEvent

For further information on what each of these event types signify, go through the All Event Types section of the documentation.