Apex
Platform Events
Platform Events Apex Handler (Object Type)
considering you've already gone through docid\ rknln6uow5ow7m1aji6xq section of the documentation, this article will walk you through how to write a trigger on the cldfs cloudfilesevent c object and handle custom logic based on the event type if you've set the setting to platform events, go through this article docid\ ejrg2isyetemkfncftw8p basic example note salesforce does not allow callouts from the trigger context therefore, please make the callout in an asynchronous context in the example below, we used a future method to make the callout https //help salesforce com/s/articleview?id=000386018\&type=1 trigger example trigger cloudfilesobjecttrigger on cldfs cloudfilesevent c (after insert) { cloudfileseventtriggerhandler execute(); } trigger handler example public with sharing class cloudfileseventtriggerhandler { public static void execute() { list\<id> recordids = new list\<id>(); for(cldfs cloudfilesevent c obj (list\<cldfs cloudfilesevent c>)trigger new){ recordids add(obj id); } processcloudfilesevents(recordids); } @future(callout=true) public static void processcloudfilesevents(list\<id> recordids) { list\<cldfs cloudfilesevent c> records = \[select id, name, cldfs data c, cldfs object type c, cldfs request id c, cldfs type c, createddate from cldfs cloudfilesevent c where id in \ recordids]; if (records size() == 0) return; //output from geteventdetails list\<cldfs event> returnedevents = new list\<cldfs event>(); //inputs for geteventdetails list\<cldfs geteventdetails flowinput> geteventdetailinputs = new list\<cldfs geteventdetails flowinput>(); //input mapping for geteventdetails for(cldfs cloudfilesevent c record records){ cldfs geteventdetails flowinput singleinput = new cldfs geteventdetails flowinput(); singleinput eventcustomobj = record; geteventdetailinputs add(singleinput); } //get the event details returnedevents = cldfs geteventdetails geteventdetails(geteventdetailinputs); //process the returned events for(cldfs event e returnedevents){ if(e type == 'document processed'){ system debug('context ==> '+e documentprocessed context); system debug('processed document id ==> '+e documentprocessed processeddocumentid); system debug('processed file details ==> '+e documentprocessed file); } } } } apex types for different platform event types line #35 in the example above displays outputs from the docid\ cbqw1iswhv8m ia49ryw 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 file uploaded docid\ rfrm0ccefnamauhq fj6x file replaced docid\ hmo1wqywiwkrvyegg1hbm salesforce file attached docid\ paouzfslqyfj1r2cpal6a salesforce file copied docid\ mck 6dm yjpvb3ku dzbj folder created docid\ a3 5ipjrcz2hyrozufkvs resource updated docid\ taj9r2evot2fyqtt9viiy content version created docid\ dactalz0owhdo4hgdza4m content version created batch docid\ wput3qqi82o5iuxv hegn file received docid\ fbfquz7bvioclhlke vjg resource attached docid\ sxyta6nleryqqykb60pob document generated docid\ syr eisyvmxipl 2rozje resource cloned docid\ qfvxwwbn8bu71vaxihorr file viewed docid 7vdtenfvihudbxovlaxlk document processed docid\ cbqw1iswhv8m ia49ryw document split docid\ n8qb7lhs9tpldgpju jiz resource deleted docid\ g0m1wfdgbj7jgbxarytqv error event docid omxqz0brj2bv7twjulvh