+ Start a Discussion
Soumyodeep Guha 8Soumyodeep Guha 8 

trigger on contentdocument not working

HI All,

i have written the below trigger on the ContentDocument object for a Before Insert scenerio, but the trigger seems not to be firing.
Can anyone help me with this, below is my code

trigger ContentDocumentTrigger on ContentDocument (Before Insert) {
    if(trigger.isInsert && trigger.isBefore){

Handler class
public without sharing class fileSharing{
    public static void publicGroupOwnership1 (list<ContentDocument> ContentDocumentRcd){
        profile adminProfile = [Select id from profile where name='System Administrator'];        
        user adminUser = [Select id, name from user where profileId=:adminProfile.id];
        for(ContentDocument ContentDocumentLoop :ContentDocumentRcd){
            ContentDocumentLoop.OwnerId = adminUser.Id;
        system.debug('$$contentDocumentRcd '+contentDocumentRcd);
Prashant Pandey07Prashant Pandey07
Hi Soumyodeep - I don't think you can execute before insert on the content document.
 ContentDocument object only supports delete(), describeSObjects(), query(), retrieve(), undelete(), update() calls.

check this post https://salesforce.stackexchange.com/questions/16441/trigger-on-contentdocument

Soumyodeep Guha 8Soumyodeep Guha 8
Hi Prashant,

thanks for the link, 
so can you let me know how can we update a particular contentDocument record. i.e from where can call or trigger the update() function on the contentdocument object