trigger CDL_OwnershipUpdate2021 on ContentDocumentLink (before insert) {
for(ContentDocumentLink CDL: trigger.New)
{
string parentId = CDL.LinkedEntityId;
string newOwner = null;
string docId = CDL.ContentDocumentId;
List<Application__c> Apps = new List<Application__c>();
Apps = [select Id, Evaluator__c from Application__c where Id = :parentId];
if(Apps != null && Apps.size() > 0){
System.debug('Checkpoint 1');
for(Application__c app: Apps)
{
newOwner = app.Evaluator__c;
}
}
ContentDocument doc = [select Id, OwnerId from ContentDocument where Id = :docId];
if(newOwner != null){
System.debug('Checkpoint 2');
doc.OwnerId = newOwner;
update doc;
}
}
}
Hi Steven,Is it possible to connect on a call and see what exactly the issue is? You can contact me on:Gmail: abhibansal2790@gmail.comSkype: abhishek.bansal2790Thanks,Abhishek Bansal.