Platform Events Apex Handler (Object Type)
considering you've already gone through events 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 platform events 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 salesforce article link 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 documentprocessed 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 attachment attachment docid 7vdkfats tonll2jilgsg content version created contentversioncreated docid\ dactalz0owhdo4hgdza4m content version created batch contentversioncreatedbatch docid\ wput3qqi82o5iuxv hegn dataroom dataroom docid\ xf4il1xefxnda d4yhc8y docgen params docgen params docid\ zrj0cckhjeobt yqj2k x document generated documentgenerated docid\ syr eisyvmxipl 2rozje document processed documentprocessed docid\ cbqw1iswhv8m ia49ryw file replaced filereplace docid\ hmo1wqywiwkrvyegg1hbm salesforce file attached salesforcefilesattached docid\ paouzfslqyfj1r2cpal6a salesforce file copied salesforcefilecopied docid\ mck 6dm yjpvb3ku dzbj folder created foldercreated docid\ a3 5ipjrcz2hyrozufkvs resource updated resourceupdated docid\ taj9r2evot2fyqtt9viiy file uploaded fileupload docid\ rfrm0ccefnamauhq fj6x file received filereceived docid\ fbfquz7bvioclhlke vjg resource attached resourceattached docid\ sxyta6nleryqqykb60pob document processed error documentprocessederror docid 2jffsbvnlumurh4wzxsx2 document split documentsplit docid\ n8qb7lhs9tpldgpju jiz drive drive docid\ zr35rimvjirhevmqtsusx error event errorevent docid omxqz0brj2bv7twjulvh file received filereceived docid\ fbfquz7bvioclhlke vjg file replace filereplace docid\ hmo1wqywiwkrvyegg1hbm file request filerequest docid\ zdw0 8n6ty2nfo4oszg2p file upload fileupload docid\ rfrm0ccefnamauhq fj6x file viewed fileviewed docid 7vdtenfvihudbxovlaxlk folder created folder created docid 86mmlvtaj92az8gbwu0i3 generateddocument generateddocument docid 5kuzh0qybdpcwxpem yjh generated document generated document docid\ wxctaochq6wt l81 7wgz link link docid\ ruyegmb59ipabacotpnuf resource resource docid\ mr7u7qdhigoasucpf nlr resource attached resource attached docid\ irpfnduqgvcodymif83fm resource cloned resourcecloned docid\ qfvxwwbn8bu71vaxihorr resource deleted resourcedeleted docid\ g0m1wfdgbj7jgbxarytqv resource updated resourceupdated docid\ taj9r2evot2fyqtt9viiy resource list resource list docid\ ufmey5fawzh3pa7u79q4s salesforce file attached salesforcefilesattached docid\ paouzfslqyfj1r2cpal6a salesforce file copied salesforcefilecopied docid\ mck 6dm yjpvb3ku dzbj salesforce file copied error salesforcefilecopiederror docid\ wdp0zoachki4yowg59vwb salesforce file salesforce file docid\ wdc3z dsbtzrpwq4a xil sharepoint site sharepointsite docid\ dspuda9urvoyfbwpeann0 update license flow output updatelicensesflowoutput docid 9cahfabthdlaq 7k4fkaf input & output types input & output types docid\ oolyuzxsiq0fcrp8i2dwb