You need to sign in to do that
Don't have an account?
Amidou Cisse
trigger to upload file on library : help
//Trigger trigger BlockContentLtrigger on ContentDocumentLink (before insert) { for(ContentDocumentLink contDocL : Trigger.new) { if (CDLHelper.isSharingAllowed(contDocL)) { contDocL.addError('stop3 '); } } } //Class public class CDLHelper { public static boolean isSharingAllowed(ContentDocumentLink cdl) { String docId = cdl.ContentDocumentId; ContentVersion version = [select PublishStatus, FileExtension from ContentVersion where ContentDocumentId =: docId].get(0); if (version.PublishStatus.equals('P') && (version.FileExtension != null)) { return false; } return true; } }
Hi Amidou,
Please use below and let me know the results :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
All Answers
Hi Amidou,
Please use below and let me know the results :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
I tried but I still have in the console an error with this line, which makes that I can not cover 100% my trigger. " System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, BlockContentLtrigger: execution of BeforeInsert
caused by: System.QueryException: List has no rows for assignment to SObject
Class.CDLHelper.isSharingAllowed: line 19, column 1
Trigger.BlockContentLtrigger: line 4, column 1: [] "
@Amidou,
The error, seems that , The below query try to tetrive records, but there is no record in database.Please use debugging to check
ContentVersion version = [select PublishStatus, FileExtension from ContentVersion whereContentDocumentId =: cdl.ContentDocumentId limit 1];
Thanks