Attaching a ContentDocument
to a Salesforce custom object
The Salesforce ODBC driver enables you to work with Salesforce by using SQL (and since version 2.0 of the driver, SOQL as well).
After you have downloaded, installed, and licensed the Salesforce ODBC driver (refer to the driver documentation), you need to set up an ODBC data source where you specify your Salesforce user name and password. You're then ready to enter some SQL in your ODBC application.
To address the subject of this blog, which was based on a customer request, this SQL statement:
insert into ContentDocumentLink (LinkedEntityId, ContentDocumentId, ShareType) Values('a000H00000sWZ9AQAW', '0690H000004bVnOQAU', 'V')
adds the specified custom object to the ContentDocument
's Shared With list in the Salesforce back-end GUI, where:
a000H00000sWZ9AQAW
is the ID of a custom object.0690H000004bVnOQAU
is the id of aContentDocument
.V (Viewer)
is aShareType/
.
The ShareType
can also be C (Collaborator)
or I (Inferred)
. However, during testing I
didn't work for us. We got an "access denied" error, which is strange since we only use one user, a system administrator, to do everything in Salesforce.