AdvoLogix Help

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

Updated on

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 Custom Salesforce Push Notification system module. The custom notification retrieved here can be used to send push notifications in Salesforce Web or Mobile devices to the recipient users added in this section of the flow.

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

  6. 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.)

  7. 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.
    • Site Address - Provide the SharePoint Site Address here. (See how to retrieve your SharePoint Site Address)
    • Login As User ID - [optional] Provide a user id (that is enabled as Secured Logins user) to automatically authenticate your SharePoint related operations within this flow action.  (For more details about this Apex Action, see this article.)
    • Use Asynchronous Method - Provide a true/false value to mark that this process is to be executed as an asynchronous approach.

  8. Send a push notification when the document is uploaded successfully in SharePoint.

  9. Send a push notification when the document upload fails with some error details encountered during the process.

  10. Send a push notification when the document upload process fails with unexpected error.

In situations where you do not want a copy of your document stored in Salesforce Files, you may add an additional action item in the flow just before Step H, 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.

Folder Path should always start with reference to your mapped folder for the Salesforce object record. 

Upload Document action requires that the related record to which Salesforce File is uploaded to should already have a mapped folder in SharePoint, without a mapped folder AdvoLogix will not copy the Salesforce Files content to SharePoint folder.

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 AdvoLogix.com 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 AdvoLogix.com LLC. All Rights Reserved.