Introduction
S-Docs integrates seamlessly with Microsoft SharePoint, meaning that you can generate documents securely on the Salesforce platform and then upload them to SharePoint -- all without ever leaving Salesforce. This article provides step-by-step instructions for configuring the S-Docs SharePoint integration.
This article assumes that you have already created a SharePoint account.
Register an App in Sharepoint
- Navigate to [YOUR SHAREPOINT DOMAIN URL]/_layouts/15/appregnew.aspxExample: https://example.sharepoint.com/_layouts/15/appregnew.aspx
- Click both Generate buttons to get the Client Id and Secret
- Complete the rest of the app
Title: Anything
App Domain: Your http://salesforce.com domain (not lightning.force.com)
Note: The URL must have a prefix of www.Ex. www.page-flow-623-dev-ed.scratch.my.salesforce.com
Redirect URL: [my.salesforce.com Domain URL]/services/authcallback/SharePointAuth
Example: https://example.my.salesforce.com/services/authcallback/SharePointAuth
- Complete the rest of the app
- Click Create
- Copy the Client Id and Client Secret and save it.
- Navigate to [YOUR SHAREPOINT DOMAIN URL]/_layouts/15/AppPrincipals.aspx
- Find your new app. Under the App Identifier column, grab the string after the “@” symbol and save it. This is the Tenent Id.
Add An Auth Provider In Salesforce
- In Salesforce, Navigate to Setup > Identity > Auth. Providers and click New.
- Select Microsoft Access Control Service for the Provider Type
- Fill in the following:
Name: SharePointAuthURL Suffix: SharePointAuth
Consumer Key: Your saved Client Id
Consumer Secret: Your saved Client Secret
Authorize Endpoint URL: [YOUR SHAREPOINT DOMAIN URL]/_layouts/15/OAuthAuthorize.aspx
Example: https://example.sharepoint.com/_layouts/15/OAuthAuthorize.aspx
Token Endpoint URL: https://accounts.accesscontrol.windows.net/[TenentId]/tokens/OAuth/2?resource=00000003-0000-0ff1-ce00-000000000000/[YOUR SHAREPOINT DOMAIN URL]@[TenentId]
Example: https://accounts.accesscontrol.windows.net/6935d4a7-bd7d-4bce-8ed2-123abc06b965/tokens/OAuth/2?resource=00000003-0000-0ff1-ce00-000000000000/example.sharepoint.com@6935d4a7-bd7d-4bce-8ed2-123abc06b965
Grant Permission To An App
- Navigate to [Domain URL with Admin suffix]/_layouts/15/AppInv.aspx (https://sdocsinc-admin.sharepoint.com/_layouts/15/AppInv.aspx)
- Paste the Client Id into the App Id field and click “Lookup” on the right
- Title, App Domain, and Redirect URL should be automatically filled. Don’t change any of them.
- Copy and paste the following into Permission Request XML:
<AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" /> </AppPermissionRequests>
- After clicking create, click Trust It on the redirected page. Make sure the name matches the title of the clients created
Create Named Credentials
-
In Salesforce, navigate to Setup > Security > Named Credentials > External Credentials tab and click New
- Fill in the following information
Label: sharePoint
Name: sharePoint
Authentication Protocol: OAuth 2.0
Authentication Flow Type: Browser Flow
Scope: null
Authentication Provider: SharePointAuth
Create Named Principal
-
In Salesforce, navigate to Setup > Security > Named Credentials > External Credentials tab > click s3Upload > Under Principals click New (Typically you are in the External Credential page after creation)
-
Fill in the following information:
Parameter Name: sharePoint
Sequence Number: 1
Identity Type: Named Principal
Scope: null
-
-
-
After adding the Named Principal, you will need to authenticate. This is done by clicking the arrow under Actions and clicking Authenticate.
-
Create Named Credential
-
In Salesforce, navigate to Setup > Security > Named Credentials and click New
-
Fill in the following information
Label: sharePoint
Name: sharePoint
URL: https://example.my.salesforce.com
External Credential: Choose sharePoint in dropdown
Generate Authorization Header: Checked
Allowed Namespaces for Callouts: SDOC
Create and Assign Permission Set to User
-
The permission set should contain the following:
-
Read access for the object: User External Credentials
-
External Credential Principal Access - “sharePoint - sharePoint”
Create A SharePoint Enabled S-Docs Template
To upload a document to Microsoft SharePoint, you must enable the template for SharePoint upload and optionally specify a SharePoint folder to upload to.
Add SharePoint Enabled Field to The Template Detail Page
From the setup menu, navigate to the Object Manager and find the SDoc Template object.
Navigate to the Page Layouts tab and click Edit for the SDoc Template layout.
Find the SharePoint Enabled field in the Fields section of the layout editor. Drag it down into the SDoc Template Detail section. Then, click Save.
Optional SharePoint Fields
You can also optionally add the SharePoint Folder Name field if you'd like to specify SharePoint folders to store uploaded documents in.
In addition, you can optionally add the Allow SharePoint Target Editing field if you'd like to grant end users the ability to modify which SharePoint folder a document should be uploaded to after generation.
Enable Your S-Docs Template for SharePoint Upload
Navigate to the template detail page for any templates you'd like to upload to SharePoint after generation, and check the SharePoint Enabled checkbox.
If you'd like to upload documents to a specific folder, you can also enter the folder name - or the path to the folder - in the SharePoint Folder Name field, as shown above.
If you'd like to grant end users the ability to modify this folder path, you can check Allow SharePoint Target Editing.
Upload Documents to Microsoft SharePoint
After generating your SharePoint-enabled template, click Upload Selected to Microsoft SharePoint.
Your document will be queued for upload, and you will be routed to the SharePoint upload page.
On this page, you can [1] view the SharePoint document library that your document is queued to upload to, as well as [2] the target folder. A pencil icon will appear if you opted to allow users to modify this field. You can also [3] remove any documents from the queue that shouldn't be included. Be sure to refresh the page after clicking Remove.
When satisfied with the SharePoint upload queue, [4] click Upload to Microsoft SharePoint.
Your document(s) will be uploaded to SharePoint, and the SharePoint Status field will present a link to view your document.
You can also view your document stored in SharePoint.
For more information about S-Docs integrations, please visit the Integrations section of the Knowledge Base.