0

Can someone please provide a sample code to create a contentfolder in a library using APEX? Do we still can't create folder without Metadata API?

1

I managed to create contentfolder using the below code

ContentWorkspace cw = [SELECT Id, Name
                     FROM ContentWorkspace
                     WHERE Name = 'My Library'
                    ];
List < ContentFolderLink > cfl = [SELECT Id, ContentFolderId, ParentEntityId
                                 FROM ContentFolderLink
                                 WHERE ParentEntityId = : cw.Id
                                ];

if (cfl.size() > 0) {
 ContentFolder cf = new ContentFolder(Name = 'subfolder', ParentContentFolderId = cfl[0].ContentFolderId);
 Insert cf;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.