Uploading Files into ContentVersion and Attachment Objects
Uploading Files into ContentVersion and Attachment Objects
Use SF_TableLoader to Upload Files
You can use SF_TableLoader
to upload files into Salesforce.com as ContentVersion or Attachment Salesforce objects. When you place a file path in the VersionData or Body column, SF_TableLoader
uses the path to obtain the data needed.
How to Find the ParentID of Content Files?
To create a file, create a new version via the ContentVersion object without setting the ContentDocumentID. This automatically creates a parent file record. When adding a new version of the file, you must specify an existing ContentDocumentID, which initiates the revision process for the file. When the latest version is published, the title, owner, and publish status fields are updated in the file.
Uploading Content
To upload content:
-
Use
SF_Generate
to generate a table for the upload. See SF_Generate for more details.EXEC SF_Generate 'Insert','Salesforce','ContentVersion_Load'
-
Using SQL, modify the VersionData column type to be a nvarchar(500) instead of an image type.
ALTER table ContentVersion_Load Drop Column VersionData ALTER table ContentVersion_Load Add VersionData nvarchar(500) null
-
Insert rows into the ContentVersion_Load table with the following values:
-
Title—file name
-
ContentDocumentID—ID of the document
-
Origin—the source of the content version. Valid values are:
-
C—This is a Content document from the user’s personal library. The label is “Content”. The
FirstPublishLocationID
must be the user ID. IfFirstPublishLocationID
is left blank, it defaults to the user ID. -
H—This is a Chatter file from the user’s My Files. Label is Chatter. The FirstPublishLocationID must be the user’s ID. If FirstPublishLocationID is left blank, it defaults to the user’s ID. Origin can only be set to H if Chatter is enabled for your organization.
This field defaults to C. The Label is “Content Origin”.
-
-
OwnerID—ID of the owner of this document
-
Description—(optional) file or link description
-
VersionData—complete file path on the local drive of the file you want to upload to Salesforce, for example:
C:serialnumber.txt
-
PathOnClient—complete file path on the local drive of the file you want to upload to Salesforce
-
ContentUrl—URL (for uploading links only, leave blank for files)
-
FirstPublishLocationID—workspace ID
-
RecordTypeID—content type ID. If you publish to a workspace that has restricted content types, you must specify RecordTypeID.
-
-
Upload the table to Salesforce.com using
SF_TableLoader
, which automatically reads the file at the location found in the VersionData column and passes the contents to Salesforce as the file.EXEC SF_TableLoader 'Insert','Salesforce','ContentVersion_Load'
NOTE: You cannot use the
bulkapi
switch when uploading content withSF_TableLoader
. -
Check Errorcolumn in the ContentVersion_Load_Result table for any error messages.
Uploading Attachments
To upload Attachments:
-
Use
SF_Generate
to generate a table for the upload. See SF_Generate for more details..EXEC SF_Generate 'Insert','Salesforce','Attachment_Load'
-
Using SQL, modify the Body column type to be a nvarchar(500) instead of an image type.
ALTER table Attachment_Load DROP Column Body ALTER table Attachment_Load ADD Body nvarchar(500) null
-
Insert rows into the Attachment_Load table with the following values:
-
Name—file name
-
Description—(optional) file description
-
Body—the complete file path on the local drive of the computer where you installed DBAmp. For example:
C:serialnumber.txt
-
IsPrivate—false/true
-
OwnerID—(optional) the file owner, defaults to the user uploading the file.
-
ParentID—ID of the parent object of the attachment. The following objects are supported as parents of attachments:
Account, Asset, Campaign, Case, Contact, Contract, Custom objects, EmailMessage, EmailTemplate, Event, Lead, Opportunity, Product2, Solution, Task.
-
-
Upload the table to Salesforce.com using
SF_TableLoader
, which automatically reads the file using the location found in the Body column and passes the contents to Salesforce as the file.EXEC SF_TableLoader 'Insert','Salesforce','Attachment_Load'
NOTE: You cannot use the
bulkapi
switch when uploading attachments withSF_TableLoader
. -
Check the Errorcolumn of the Attachment_Load_Result table for any error messages.