-
-
Save thepaulfox/3f525d0c5f9856d5ca50 to your computer and use it in GitHub Desktop.
Why won't ContentDocument Trigger Fire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger ContentDocumentTrigger on ContentDocument (before delete){ | |
System.Debug('Trigger Fired'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Id MyId = '[fill this in]' // Use some record that has feed items enabled | |
FeedItem myPost = new FeedItem(ParentId = MyId | |
, ContentData = Blob.valueOf('anImage') | |
, ContentFileName = 'testFeedItem.jpg'); | |
insert myPost; | |
myPost = [SELECT RelatedRecordId | |
FROM FeedItem | |
WHERE Id = :myPost.Id]; | |
System.Debug(myPost.RelatedRecordId); | |
ContentDocument doc = [SELECT Id FROM ContentDocument WHERE Id = :myPost.RelatedRecordId]; | |
delete doc; // Comment this out when you want to test via UI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you save the trigger into your org and then run the execute anonymous code then you'll see that the trigger never fires.
However, if you comment out line 11 of the execute anonymous code then you can get the doc id and delete it through the UI. THEN the trigger will show up in the debug logs...