I'm trying to create subfolders within my existing Salesforce libraries (ContentWorkspaces) & struggling with the apparent lack of documentation. I have 4 issues:
- Understanding how the hierarchy is structured
- Creating a ContentFolderLink
- Creating a ContentFolderLink before a root ContentFolder exists
- Enabling / checking that folders are enabled for my ContentWorkspace
Am I right in thinking that the hierarchy should look like:
ContentWorkspace | ContentFolderLink | ContentFolder | ContentFolderMember
Based on the description for the ContentFolderLink object in the release notes
In a ContentWorkspace that has folders enabled, defines the association between the ContentWorkspace and its root ContentFolder.
I need to create a ContentFolderLink, in order to create a ContentFolder subfolder.
When I try to create a ContentFolderLink
ContentWorkspace cw = [SELECT Id,Name FROM ContentWorkspace WHERE Name = 'Library Name']; ContentFolderLink cfl = new ContentFolderLink(ParentEntityId=cw.Id); Insert cfl;
it causes an error
Field is not writeable: ContentFolderLink.ParentEntityId
how should I resolve this?
I expect I need to create a ContentFolder before I create the ContentFolderLink so that I have an Id for the ContentFolderLink's ContentFolderId field, however when I try to create the folder
ContentWorkspace cw = [SELECT Id,Name FROM ContentWorkspace WHERE Name = 'Library Name']; ContentFolder cf = new ContentFolder(Name='Subfolder',ParentContentFolderId=cw.Id); Insert cf;
it causes an error
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Parent Content Folder ID: id value of incorrect type: 0585400000058bZAAQ: [ParentContentFolderId]
I assume that I should be setting the ContentFolder's ParentContentFolderId as the ContentFolderLink but it won't have an Id until it's inserted, how should this sequence work?
I would expect to see a boolean field for the object to indicate whether folders have been enabled for the library / ContentWorkspace but there isn't one listed in the API developer guide. How can I check / enable this setting?