Salesforce File XML
Tasks
This task will create or update multiple files in Salesforce, and optionally link them to existing records. The example below shows how to upload a PDF file, and link it to the account with name 'Zynk Software'.
XML
<?xml version="1.0"?>
<Files>
<File>
<Title>Invoice 0000238052</Title>
<FilePath>C:\Invoices\invoice_0000238052.pdf</FilePath>
<IsMajorVersion>true</IsMajorVersion>
<Description>Sage invoice 0000238052</Description>
<PublishStatus>P</PublishStatus>
<ReasonForChange>Discount applied</ReasonForChange>
<TagCsv>Invoice,PDF</TagCsv>
<FileLinks>
<FileLink>
<LinkedEntityLookup Select="Id" From="Account">
<WhereField Name="Name" Value="Zynk Software" />
</LinkedEntityLookup>
<ShareType>I</ShareType>
<Visibility>AllUsers</Visibility>
</FileLink>
</FileLinks>
</File>
</Files>
In each of the following sections most of the XML has been omitted to make the samples easier to read. The whole structure of the SalesforceObjects schema is used below as a reference of where fields should be in the object model.
File
The File element represents a file to upload to Salesforce. This element appears as a child of the root Files element. Multiple File elements can be provided.
| XML Field | Type | Input | Example | Description |
|---|---|---|---|---|
| ContentDocumentId | id | Optional | 0698Z00000a8n5wQAA | If you know the ID of the ContentDocument you want to update, set it here |
| Title | string | Required | Invoice 0000238052 | The title of the file. Used for matching the ContentDocument if ContentDocumentId is not specified |
| FilePath | string | Dependant | C:\Invoices\invoice_0000238052.pdf | Used to upload a local file to Salesforce. Supports relative paths. Required if FileUrl isn't provided. |
| FileUrl | string | Dependant | https://www.example.com/invoice_0000238052.pdf | Used to link a file on the web to Salesforce. Required if FilePath isn't provided. |
| PathOnClient | string | Optional | invoice_0000238052.pdf | The file name. Will be set automatically based on the FilePath or FileUrl if not specified. |
| IsMajorVersion | bool | Optional | true | Set to true if this represents a major version of the file. |
| Description | string | Optional | Sage invoice 0000238052 | A description of the file. |
| PublishStatus | enum | Optional | P | P - Public, R - Personal Library, U - Upload Interrupted |
| ReasonForChange | string | Optional | Discount applied | The reason why the file was changed. |
| TagCsv | string | Optional | Invoice,PDF | A comma separated list of tags to apply. |
| FileLinks | FileLink | Optional | N/A | See FileLink for more info. |
<?xml version="1.0"?>
<Files>
<File>
<ContentDocumentId>0698Z00000a8n5wQAA</ContentDocumentId>
<Title>Invoice 0000238052</Title>
<FilePath>C:\Invoices\invoice_0000238052.pdf</FilePath>
<FileUrl>https://www.example.com/invoice_0000238052.pdf</FileUrl>
<PathOnClient>invoice_0000238052.pdf</PathOnClient>
<IsMajorVersion>true</IsMajorVersion>
<Description>Sage invoice 0000238052</Description>
<PublishStatus>P</PublishStatus>
<ReasonForChange>Discount applied</ReasonForChange>
<TagCsv>Invoice,PDF</TagCsv>
<FileLinks>
<!-- See below -->
</FileLinks>
</File>
</Files>
FileLink
The FileLink element represents a link between a file and another record in Salesforce. This element appears as a child of the FileLinks element. Multiple FileLink elements can be provided.
| XML Field | Type | Input | Example | Description |
|---|---|---|---|---|
| LinkedEntityId | id | Dependant | 0014000000Lgdn8AAB | The Id of the record to link the file to. Required if LinkedEntityLookup is not provided. |
| LinkedEntityLookup | LookupField | Dependant | See below | Used to search for a record to link the file to. See LookupField for more info. Required if LinkedEntityLookup is not provided. |
| ShareType | enum | Optional | I | V - Viewer permission, C - Collaborator permission, I - Inferred permission |
| Visibility | enum | Optional | AllUsers | AllUsers, InternalUsers, SharedUsers |
<?xml version="1.0"?>
<Files>
<File>
<FileLinks>
<FileLink>
<LinkedEntityId>0014000000Lgdn8AAB</LinkedEntityId>
<LinkedEntityLookup Select="Id" From="Account">
<WhereField Name="Name" Value="Zynk Software" />
</LinkedEntityLookup>
<ShareType>I</ShareType>
<Visibility>AllUsers</Visibility>
</FileLink>
</FileLinks>
</File>
</Files>