Integrating Salesforce with Microsoft SharePoint Using File Connect

Sombir Sheoran
7 min readJul 28, 2022

--

The perfect match of the best CRM (Salesforce) and a feature-stuffed Microsoft-powered document management system SharePoint

Integrating Salesforce with Microsoft SharePoint Using File Connect
Integrating Salesforce with Microsoft SharePoint Using File Connect

Please note that this is a point-and-click solution using the standard File Connect feature in Salesforce and requires no code in writing. SharePoint App details, Mircosoft 0365 Org. Details and Salesforce URLs would change for everyone building this solution. Details mentioned in this document are for reference purpose only.

Making SharePoint Site Ready (Microsoft o365 Account is needed)

Create a Microsoft SharePoint trial account in the case already does not exist (Developer trial). This would help you get access to MS o365 Trial for 90 days including SharePoint access.

  1. Launch https://developer.microsoft.com/en-us/microsoft-365/dev-program and click on Join now, and fill in the required details
  2. Complete details here to create an MS o365 Trial Account: https://www.sharepointdiary.com/2021/05/how-to-create-sharepoint-online-free-trial-account.html
  3. Once done, you can check your complete profile here: https://developer.microsoft.com/en-us/microsoft-365/profile which includes your domain name e.g. below, and Administrator user name: example: 6kn6y3.onmicrosoft.com
  4. Once your SharePoint access is ready, you need to create a new site (Private or Public) from https://6kn6y3.sharepoint.com/_layouts/15/sharepoint.aspx
  5. Create Site > Create a site > Type = Team Site > Give it a Site Name and Site Description and note down the site URL
Creating a Site

6. The site URL should be like: https://6kn6y3.sharepoint.com/sites/fileconnectwithsp

where fileconnectwithsp is the site name.

Enable Salesforce File Connect in Salesforce

  1. From Setup, search for Files Connect and make sure it is Enabled:
File Connect in Salesforce

2. File Sharing can be selected Copy or Reference as per client need:

Files Connect Settings

User Permission Sets Creation for Files Connect access

  1. Create a new permission set: FilesConnect Permission Set
  2. Add below access to this permission set record:

Add this System permission: and assign it to respective users who need SharePoint access from Salesforce.

Files Connect Cloud : Access cloud-based external content sources, such as SharePoint Online.

Auth. Provider Setup inside Salesforce

Auth. Provider Salesforce Documentation:

Auth. Provider Detail

Go to Salesforce Setup > Auth Providers and create a new record with Provider Type = Microsoft Access Control Services. It supports a lot of provider types including Google, Apple, Facebook, Twitter, Slack, LinkedIn, and so on.

Enter the Name and URLSuffix, and for the time being, enter a dummy value for Consumer Key, Consumer Secret, Authorize Endpoint URL, and Token Endpoint URL (you may have to include HTTP:// for getting the URL fake values right.

Later these details to be confirmed and taken from the SharePoint App which we would create in the upcoming steps. Final Details are updated in the screenshot for time saving.

Creating New Auth. Provider in Salesforce

Complete details should look like as below:

Sample Auth. Provider Details, Details would vary as per the org.

Where

  • In the field of Authorize Endpoint URL, you would have to enter the value https://[your company name].sharepoint.com/[site collection path]/_layouts/15/OauthAuthorize.aspx
  • In the field of Token Endpoint URL, enter the value https://accounts.accesscontrol.windows.net/[your company name].onmicrosoft.com/tokens/OAuth/2?resource=00000003–0000–0ff1-ce00–000000000000/[your company name].sharepoint.com@[your company name].onmicrosoft.com

where [your company name] = 6kn6y3 in our case. This will vary in every case as per the SharePoint account details.

Create SharePoint App for Salesforce integration

This SharePoint App details would be needed to re-configure the Auth. Provider in earlier steps once our App is ready and configured.

  1. We can create a new SharePoint App by appending _layouts/15/appregnew.aspx at the end of the SharePoint Site Collection URL [sites/fileconnectwithsp]
  2. URL Format : https://[your company name].SharePoint.com/[site collection path]/_layouts/15/appregnew.aspx
  3. For our project, the full URL should be https://6kn6y3.sharepoint.com/sites/fileconnectwithsp/_layouts/15/appregnew.aspx. This would launch the below page where Client Id and Client Secret can be generated by the buttons given and the rest of the details can be entered manually as per the requirement.
Creating New SharePoint App

4. Create a new App named SharePointOnlineFC with below final details: The app identifier has been successfully created:

Please note them down in a notepad for later usage.

Sample App details. Please note them down in a notepad for later usage.

Where

App Domain: is Salesforce classic base URL and

Redirect URI: is the Callback URL from the Auth. Provider** (URL below for our Salesforce org.) https://playful-otter-pxypju-dev-ed.lightning.force.com/lightning/setup/AuthProviders/page?address=%2F0SO5h0000000BrP

Auth. Provider set-up would be done in the next few steps.

Configuring SharePoint App for Salesforce integration

  1. We need to configure our newly created SharePoint App for the necessary level for Access grants, by appending _layouts/15/appinv.aspx at the end of the SharePoint Site Collection URL [sites/fileconnectwithsp]
  2. Complete URL format: https://[your company name].SharePoint.com/[site collection path]/_layouts/15/appinv.aspx
  3. For our sample project, the full URL should be : https://6kn6y3.sharepoint.com/sites/fileconnectwithsp/_layouts/15/appinv.aspx
  4. App Id is the Client Id for the newly created App above. Search with App Id = Client Id and click Lookup. It will search and Load the App created in the previous step.
  5. This will auto-populate the values of other boxes except for Permission Request XML. The value of Permission Request XML, as the title suggests, defines the level of access the connecting application will have in respect to accessing SharePoint files collections. The standard input is as below:

<AppPermissionRequests>
<AppPermissionRequest Scope=”[SCOPE]” Right=”[PLACEHOLDER]”/>
</AppPermissionRequests>

Sample Permission Request XML:

<AppPermissionRequests><AppPermissionRequest Scope=”http://sharepoint/content/sitecollection" Right=”FullControl”/></AppPermissionRequests>

For SharePoint Online, replace [SCOPE] with one of these values.

IMPORTANT Office 365 recognizes only these scope URLs; copy them exactly, without changes.

Replace [PLACEHOLDER] with one of these values:

  • Read
  • Write
  • Manage
  • FullControl
    For details about the differences between permission levels above, see the Microsoft website.

🚩Tip : Sometimes, we need Tenant Id also, mostly during testing SharePoint APIs with Postman or during real API integration development between Salesforce and Sharepoint. Append _layouts/15/appprincipals.aspx at the end of site URL to get the all site collection permissions and hence the Tenant Id.
In our case, URL will become : https://6kn6y3.sharepoint.com/sites/fileconnectwithsp/_layouts/15/appprincipals.aspx, which shows all site collections details and their permissions. Value mentioned after @ symbol under App identifier is the Tenant Id or Realm-id for your site collections. 6kn6y3 on other hand is the host name.

Fetching Tenant Id for your site

Configuring External Data Sources, using the Auth. Provider created above

  1. Within Salesforce, create a new external data source with the below details, using the Auth. Provider created in the earlier steps.

For the new External Data Source, select Type = File Connect: Microsoft SharePoint Online

Creating new External Data Source

New External Data Source Details once ready: →

Configuring external data source using newly created Auth. Provider

2. At the end once setup, click Validate and Sync in order to Sync the data/tables from the external system (SharePoint in our case)

3. Once Sync Status = COMPLETE, a new Table gets inserted and a new External Object got created items_SharePointFileConnect

4. Sometimes, errors might come while Validate and Sync, just wait or refresh the page to get the latest status until Status = COMPLETE

5. External Data Source page layout can be adjusted to show the required fields as needed by the business, under Set up > External Objects > Page layout > Edit

New External Data Source details

User Permission Sets Creation for Files Connect access

  1. Now we need to add newly created Custom Object (External) and External Data Source to the already created permission set: FilesConnect Permission Set in one of the earlier steps
  2. Add below access to this permission set record:

Add below permissions : and assign to respective users who need SharePoint access from Salesforce. In this case, assign to your user.

New permissions details

Validating if Salesforce can access the SharePoint Files

  1. Salesforce Lightning > go to Files tab, you should be able to see a New Connected Source which is created above
Newly created File Connect Source: Image 1
Newly created File Connect Source: Image 2

2. Salesforce classic: Go to any object (let's say Opportunity) > Under Files > Select a File from Salesforce > Click

Salesforce Classic — Select a File from Salesforce

3. You should be able to see All files and folders from the SharePoint path : https://6kn6y3.sharepoint.com/sites/fileconnectwithsp/Shared%20Documents/Forms/AllItems.aspx

All files and folders from the SharePoint path

4. Select any file and it gets attached to the Salesforce Opportunity record.

SharePoint file connected to Salesforce Opportunity record! Success :)

Troubleshooting

If you see errors like ‘You are not authorized to perform that operation in Files Connect Office 365 It means SharePoint App was not provided proper level of access using SCOPE and RIGHT properties.

Refer to the below article to fix the same:

Congratulations, it confirms that Salesforce to SharePoint integration is working perfectly. !

References:

https://help.salesforce.com/s/articleView?id=sf.admin_files_connect_overview.htm&type=5

https://help.salesforce.com/s/articleView?id=000335285&type=1

Developer details:

Please reach out to me for any suggestions or feedback. Would love to hear them ❤

If you loved this post, please applaud me at the end of this post with a 👏

--

--

Sombir Sheoran
Sombir Sheoran

Written by Sombir Sheoran

I'm a Certified Salesforce Consultant ☁️ who loves to write technical blogs, which help simplify Salesforce solutions. Follow to learn more ✨⚡

Responses (1)