+ Start a Discussion
Daniel BallingerDaniel Ballinger 

Determine if the current user has access to the Salesforce CRM Content features via the Partner API

Using describeGlobal() I can confirm ContentVersion and ContentDocument are available as objects for the current organization.


Using describeSObject() I can confirm that the the current users session marks ContentVersion as createable. I've also confirmed that the fields I'm setting when inserting the ContentVersion record are marked as createable (PathOnClient, VersionData and FirstPublishedLocationId).


In my test cases, if the user has access to the Content area via the Salesforce web interface then the test case passes with the ContentVersion being created.


However, when I try the same code from a developer edition org (without access to the Content area) it falls over with the message:

FIELD_INTEGRITY_EXCEPTION - User doesn't have access to Salesforce Content. Invalid field value:: Content Origin

The createable Partner API metadata for ContentVersion and the fields indicated that this should have worked.


I've tried checking ContentDocument.creatable, but this is false even for users who can otherwise create Content.


I'm working in C#, but the Java code in recipe Publishing Documents Into a Salesforce CRM Content Personal Workspace is doing much the same thing without the creatable metadata checks.

Daniel BallingerDaniel Ballinger

I think I've figured it out. Checking that ContentVersion is creatable alone is not sufficient.

I also needed to check that the current user (as indicated by getUserInfo()) has the field UserPermissionsSFContentUser and that it is true.

From the Web Services API Developer's Guider for User.UserPermissionsSFContentUser.

Indicates whether the user is allocated one Salesforce CRM Content User License (true) or not (false). Label is Salesforce CRM User. The Salesforce CRM Content User license grants the user access to the Salesforce CRM Content application.