0

I'm trying to create subfolders within my existing Salesforce libraries (ContentWorkspaces) & struggling with the apparent lack of documentation. I have 4 issues:

  1. Understanding how the hierarchy is structured
  2. Creating a ContentFolderLink
  3. Creating a ContentFolderLink before a root ContentFolder exists
  4. Enabling / checking that folders are enabled for my ContentWorkspace

Question 1

Am I right in thinking that the hierarchy should look like:

  ContentWorkspace
        |
 ContentFolderLink
        |
  ContentFolder
        |
ContentFolderMember

Question 2

Based on the description for the ContentFolderLink object in the release notes

ContentFolderLink

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?

Question 3

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?

Question 4

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?

  • Is anything other than API access available for this feature? This Idea: success.salesforce.com/ideaview?id=087300000007srnAAA "The APIs were delivered in the Summer 15 release; the UI experience is targeted for an upcoming release (safe harbor). This is when your end users will be able to see Folders and Sub Folders in the out of the box Salesforce UI. It's a staged approach where we release APIs first and then a UI for end users." – cropredy Dec 16 '16 at 1:13
  • As far as I can tell, it's still API access only at the moment. – Alex S Dec 16 '16 at 1:16
  • I don't think your schema assumption is right - ContentFolderLink is a junction between ContentFolder and ContentWorkspace. Some of these objects are not API-creatable. Similar to ContentDocument - it gets created implicitly – cropredy Dec 16 '16 at 1:19
  • That seems like bad news for me - so all of the existing standard junction objects can only be created through the UI? That's why I was confused by the ContentFolder issue (question 3) too. – Alex S Dec 16 '16 at 1:23
  • I don't have an exact answer but you are playing with what seems to be an incomplete implementation. If you are Premier Support, you can get more details that way. Others may have more info – cropredy Dec 16 '16 at 1:26
1

I did raise a Case with the Salesforce support team & the Tier 3 team confirmed that the create operation is not supported for ContentFolderLinks & although they were able to create 2 folders, that were linked together via the ParentContentFolderId field, those folders were not visible in the Library UI.

However, I checked the Spring '17 release notes & it turns out that subfolders will be available for users to manage in Lightning Experience which solves my problem.

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.