Configure Sharepoint with Named Credentials


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

  1. Navigate to [YOUR SHAREPOINT DOMAIN URL]/_layouts/15/appregnew.aspxExample:
  2. Click both Generate buttons to get the Client Id and Secret
    1. Complete the rest of the app
      Title: Anything
      App Domain: Your domain (not
      Note: The URL must have a prefix of www.Ex.
      Redirect URL:
      [ Domain URL]/services/authcallback/SharePointAuth

  3. Click Create
  4. Copy the Client Id and Client Secret and save it.
  5. Navigate to [YOUR SHAREPOINT DOMAIN URL]/_layouts/15/AppPrincipals.aspx
  6. 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

  1. In Salesforce, Navigate to Setup > Identity > Auth. Providers and click New.
  2. Select Microsoft Access Control Service for the Provider Type
  3. 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
    Token Endpoint URL:[TenentId]/tokens/OAuth/2?resource=00000003-0000-0ff1-ce00-000000000000/[YOUR SHAREPOINT DOMAIN URL]@[TenentId]

Grant Permission To An App

  1. Navigate to [Domain URL with Admin suffix]/_layouts/15/AppInv.aspx (
  2. Paste the Client Id into the App Id field and click “Lookup” on the right
  3. Title, App Domain, and Redirect URL should be automatically filled. Don’t change any of them.
  4. Copy and paste the following into Permission Request XML:
    <AppPermissionRequests AllowAppOnlyPolicy="true"> 
      <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />

  5. After clicking create, click Trust It on the redirected page. Make sure the name matches the title of the clients created

Create Named Credentials

  1. In Salesforce, navigate to Setup > Security > Named Credentials > External Credentials tab and click New

  2. 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

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

    2. Fill in the following information:
      Parameter Name: sharePoint
      Sequence Number: 1
      Identity Type: Named Principal
      Scope: null

    1. After adding the Named Principal, you will need to authenticate. This is done by clicking the arrow under Actions and clicking Authenticate.

Make sure the name is the same as the title of the client created previously and click Trust It. Then the page should redirect you back to salesforce

Create Named Credential

  1. In Salesforce, navigate to Setup > Security > Named Credentials and click New

  2. Fill in the following information
    Label: sharePoint
    Name: sharePoint
    External Credential: Choose sharePoint in dropdown
    Generate Authorization Header: Checked
    Allowed Namespaces for Callouts: SDOC


Create and Assign Permission Set to User

  1. The permission set should contain the following:

  2. Read access for the object: User External Credentials

  3. 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.

Note: You can use merge fields to insert the SharePoint folder name. Ensure you use single curly braces instead of double.



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.

Was this helpful?