createContentVersion
Uploads a file into Salesforce as either a new file or a new version for an existing file. This command creates a new ContentVersion record, which also results in the creation of a new ContentDocument record when uploading a new file.
Parent commands
createFeedAttachment
Optional. If this parent command has itscontentRecordID
attribute undefined, the file uploaded by this child command will become an attachment for a Chatter post.
Child commands
field
Optional. Add afield
child command to set a field value for the created ContentVersion record. Useful if your ContentVersion object has custom fields.
Attributes
var | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | No |
Defines the name of a variable that will receive result data of the upload operation. The value will be a Map with the following keys:
If not defined, the result data is not stored anywhere. |
doc | ||
---|---|---|
Required | Value type | EL-evaluated |
No | File | Yes |
Defines the file that is uploaded. If not defined, the uploaded file is the currently active Dynamo template. |
contentDocumentId | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines that the uploaded file will be a new version of an existing file. The resolved String should be the ID of a ContentDocument record. If undefined, the file will be uploaded as a new file, creating a new ContentDocument record in addition to the ContentVersion. |
contentType | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Use this attribute to set the record type of the created ContentVersion. The resolved String should be the Name of a RecordType record. |
title | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the title of the created ContentVersion record, which will appear as the title of the file in Salesforce. If not defined, the title will be the name of the resolved File value of the |
pathOnClient | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the value of the PathOnClient field for the ContentVersion record, which Salesforce uses to define the type of the file (PDF, DOCX, etc.). The resolved String should therefore have a file suffix appropriate for the uploaded file data. If not defined, the value will be the file name of the resolved File value of the |
firstPublishLocationId | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
This attribute can be used to define where a new file is first published. If the resolved String is the ID of a ContentWorkspace record, the file will be published into the corresponding CRM Library. Defining this attribute when creating a new version for an existing document does nothing - this attribute is only effective when the first ContentVersion for a file is created. If not defined when creating a first version, the file will be published into the active user's personal library. |
reasonForChange | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines the reason why a new version for the file was created. This reason will appear in the Salesforce UI as part of the version data. This attribute does nothing when creating the first ContentVersion for a file. |
linkToId | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
If creating the first version of a file and this attribute has a value defined, the file is shared with the record whose ID the value specifies. This link causes the file to inherit access permissions of the record and the file can appear on the record's page in Salesforce, depending on the record's page layout. |
Examples
When creating the first version of a file with this command, where the file appears and how it can be accessed needs to be decided.
A file can be linked to a record, such as an Opportunity, in which case it may appear on the record's page in a list labelled "Files" or such. Everyone able to view that record will then be able to view the file as well. To do this, set the linkToId
attribute of the createContentVersion
command into the ID of the record you wish to link the file to.
<createContentVersion doc="${document}" linkToId="${mainRecordId}">
A file can be presented in a record's Chatter feed as an attachment of a post. The postFeedItem and createFeedAttachment commands are needed for this. You can take a look at their documentation for more details, but a basic case of creating a new post with your file as its attachment can be created with the following structure.
<postFeedItem parentId="${mainRecordID}"><createFeedAttachment><createContentVersion doc="${document}">
A file can also be placed into a CRM Content library, where it will follow the access permissions of that particular library. To do this, set the firstPublishLocationId
attribute of the createContentVersion
command into the ID of the library (aka. ContentWorkspace record) you wish to place the file in.
<createContentVersion doc="${document}" firstPublishLocationId="${libraryId}">
To create a new version of an already existing file, set the contentDocumentId
attribute to the ID of the ContentDocument record of the target file.
<createContentVersion doc="${document}" contentDocumentId="${contentDocID}">