AdvoLogix Help

How do I auto-upload Salesforce Files to a SharePoint Folder via automation?


AdvoLogix® provides a built-in Apex method to auto-upload Salesforce® Files to a SharePoint® Folder via Salesforce® Flows.

Creating a Flow to Upload a Salesforce® File to a Folder within SharePoint®

A background automation can be set using a Platform Event which AdvoLogix® generates for any new Salesforce File uploaded in your organization. AdvoLogix® provides a Flow Template named SharePoint: Upload Document, which includes the preconfigured setup of actions needed to accept an uploaded Salesforce® File, read the file's associated record and then find the root folder in SharePoint® associated with that record and upload the file to a specific folder within the mapped folder.

  1. In Salesforce® setup, enter Flows into the Quick Find box and select Flows.
  2. Select the New Flow action button in the page header to initiate a new Salesforce® flow wizard.
  3. Switch to the All + Templates tab.
  4. Select the SharePoint: Upload Document template from the list of available templates.
  5. Select the Next button.

You now have a custom flow that will be triggered when a Salesforce® File is uploaded. Your administrator can customize the flow elements, including setting up more decision elements or applying more notification elements to inform users about uploaded document actions.

Understanding the Upload Document Flow Template Structure

  1. Choose SharePoint Event as the platform event Trigger mechanism. AdvoLogix® generates this platform event whenever a new Salesforce® File is created within your organization.

  2. Add a decision element to filter down the platform events to a specific type that identifies a Salesforce® File has been generated in your organization. AdvoLogix® always generates this platform event with Type = SALESFORCE_FILE_ADDED.

  3. After validating the type of platform event, we retrieve the details of the saved Salesforce® File using Get Salesforce File Data and Get all Linked Entities to the Salesforce File elements which provides all of the fields' data for the Salesforce® File and all linked entities such as account, case, or other object records this file is associated with at present, respectively.

  4. A loop element that traverses all of the linked entities of the Salesforce® File.

  5. A decision check has been added to further filter down which specific linked record's workspace we would like the saved file to be uploaded to in SharePoint®. This decision is being made using the first three character-based identification of the linked entity's record id, which remains unique throughout your organization's objects and can easily identify the object type of the linked record.
    (If you want to copy a Salesforce® File for a different linked object, then you should change this element decision criteria to verify a different object as the flow template will be set to check for the account as the default linked entity for the uploaded Salesforce® File.)

  6. Execute Upload Document, labeled as Upload Documents to SharePoint, Apex action provided by AdvoLogix® as a SharePoint® utility method. Upload Document Apex method supports the following parameters:
    • Content Version ID - Provide the Salesforce® File record's record Id value here.
    • Salesforce Record ID - Provide the Salesforce® record Id value. 
    • Folder Path - Provide the path to the folder that exists within the root folder mapped to your Salesforce® record.
    • User ID - (optional) Provide a user id to automatically authenticate your SharePoint® related operations within this flow action.
      (For more details about this Apex Action, see this article.)

  7. Make a chatter post on the record when the document is uploaded successfully in SharePoint®.

  8. Make a chatter post on the record when the document upload fails with some error details encountered during the process.

  9. Make a chatter post on the record when the process to find all associated workspaces is encountered with any error.

In situations where you don't want a copy of your document stored in Salesforce® Files, you may add an additional action item in the flow just before Step G, and add a Delete Records action element to delete the Salesforce® File or update the Salesforce® File with reference to your newly uploaded SharePoint® document's URL.

Due to certain platform limitations, only a small size document (maximum 3 MB) can be transferred from Salesforce® Files to SharePoint®.

Previous Article Creating a SharePoint Folder Via Automation
Next Article Apex Invocable Methods Available Within the Connector
Still need help? Click here!
AdvoLogix® is a registered trademark of LLC a Texas Limited Liability Company. All references to other trademarks belonging to third parties that appear on this website, documentation, or other materials shall be understood to refer to those registered trademarks owned by others, and not to any trademark belonging to AdvoLogix. Otherwise, all material herein is the copyright of LLC. All Rights Reserved.