You need to sign in to do that
Don't have an account?
sfdcdude
Trigger on content document
Hi Team,
I have added notes and attachments to custom object__c. when user deletes a file from content document object or content document link object, I need to throw an error to user. Please post code if you have handy.
Thanks.
I have added notes and attachments to custom object__c. when user deletes a file from content document object or content document link object, I need to throw an error to user. Please post code if you have handy.
Thanks.
The above code is not working and i tried with below one, and in debug it is showing parent ID value as null. Please crct if i did something wrong.
public static void restrictDeleteFiles(list<ContentDocument> oldlistContentDocument) {
for (ContentDocument cd : oldlistContentDocument ) {
system.Debug('parent id is----'+cd.ParentId);
if(cd.ParentId.getSObjectType().getDescribe().getName() == 'custom_object__c'){
cd.adderror('You Cannot delete a record once uploaded.');
}
}
}