You need to sign in to do that
Don't have an account?
How to insert a file into a library folder named 'Test' when the file is attached to a record by trigger?
Hello
I'm trying to save attachment file into a library folder named 'Test' when file is attached to a custom records and updating field of record same time.
Here is my trigger below.
Please anyone help me to add some code for inserting file into library.
trigger UploadfileintoTest on ContentDocumentLink (after insert, after update) {
List<ContentDocumentLink> cdls = ( Trigger.new == null ? Trigger.old : Trigger.new );
Set<ID> parentIds = new Set<ID>();
for (ContentDocumentLink cdl : cdls) {
parentIds.add( cdl.LinkedEntityId );
}
for (List<Person__c> prn : [SELECT Id, (SELECT Id FROM ContentDocumentLinks LIMIT 1)
FROM Person__c WHERE Id IN :parentIds]) {
for (Person__c pr : prn) {
pr.Skill_sheet_last_update_date__c = System.today();
}
UPDATE prn;
}
List<ContentWorkspace> cw = [SELECT Id, RootContentFolderId FROM ContentWorkspace WHERE Name = 'Test' LIMIT 1];
}
Does the below code help
If this information helps, please mark the answer as best. Thank you
Hello, @Swetha.
Thank you for your kind response :)
I tried above code, but above code is not working.
Please if anybody has an idea to insert related file to specific folder, please let us know how to do.
Thank you.
By not working, do you see any error?Thanks