How To Upload & Share Documents to the Microsoft SharePoint Using Business Central

Hi Readers,

I hope you and your family are healthy and safe during these unprecedented moments.

Today I was working on MS Dynamics 365 Business Central and have seen an awesome feature by little-bit of customization you can achieve so I would like to share with you.
Before going to start I would like to discuss some prerequisites and overview.

Introduction / Aim:

  • You can upload & Share any document from Microsoft Business Central Attachment page.
  • In this blog you will learn how to create SharePoint sites using office 365 credentials and setup MS SharePoint connection in the MS Dynamics 365 business central.
  • In this demo I will create a “Document Attachment Details” page extension to add the Upload & Share action, so the end user can upload and share the attachment.

Pre-requisites:

  • Microsoft office 365 SharePoint
  • Microsoft Dynamics 365 Business Central
  • Microsoft Visual Studio Code

Demonstration:
Step 1:

  • Open the MS SharePoint online and create a site (if not exists).
  • To open/create a share point site you need a valid office365 credential.
  • Login to the below URL and click on SharePoint button as shown below screenshot.
  • https://portal.office.com/ or https://www.office.com/
SharePoint portal
SharePoint Login
  • A SharePoint window will open in the next tab as shown below screenshot.
  • Click on Create action to create a new site as shown below screenshot.
SharePoint Site Creation
SharePoint Site Creation
  • Choose the type of site you would like to create as shown below screenshot.
SharePoint Site Creation
SharePoint Site Creation
  • Enter the Site Name, Site Description and Click on Next button as shown below screenshot.
Sharepoint Site Creation
Sharepoint Site Creation
  • If you would like to add additional owners then add members or else click on Finish button as shown below screenshot.
Sharepoint Site Creation 04
Sharepoint Site Creation 04
  • SharePoint site has been published and ready to upload & share the documents as shown below screenshot.
  • Click on Documents Repository and click on + New to create a folder to better organizing the documents as shown below screenshot.
Sharepoint Site Creation 05
SharePoint Site Creation 05
  • Now Share point is ready, next step to configure the connection in the business central which is described in Step 2.

Step 2:

  • Login to the Business Central Client and click on search button and choose the related link as shown below screenshot.
Search in Business Central
Search in Business Central
  • A Microsoft Sharepoint Connection Setup will be open as shown below screenshot.
  • Fill the details which we had created in the step 1 while setup the Sharepoint site.
  • Note: In this screenshot, I have filled dummy data to better understanding.
MS SharePoint Configuration
MS SharePoint Configuration
  • Setup the office365 user password which is responsible to upload the documents into Sharepoint site as shown below screenshot.
  • User must should have permission to Upload/Edit/Share permission in the Office365.
  • My recommendation is assign the user and password which was used for creating the Sharepoint site.
Set SharePoint Password
Set SharePoint Password
  • After setup the password test the connection by clicking on Test Connection action as shown below screenshot.
Test Sharepoint Connection
Test SharePoint Connection
  • Now MS SharePoint connection setup has been successfully done, in the next step I will describe how to create a page extension and adding an action to upload & Share the document.
  • End user will receive an email notification to get the shared document.

Step 3:

  • Open a new project from Visual Studio Code or you can use your existing extension.
  • Create an extension of the “Document Attachment Details” page and add an action to “Upload & Share”.
  • Also create a new page to get the email id’s from run time (business central client), so that you can send an email notification. First I’m going to create a new page and later will create an extension.
  • See the below screenshots.
Document Sharing Option Code Snap 01
Document Sharing Option Code Snap 01
Document Sharing Option Code Snap 02
Document Sharing Option Code Snap 02
Document Sharing Option Code Snap 03
Document Sharing Option Code Snap 03
  • Create an extension of the Document “Attachment Details” page as shown below screenshot.
  • In the “Upload & Share” action will do the following process:
  • Save the attachment in the temporary path
  • Get the Document Service record which has Sharepoint configuration.
  • Call the method SaveFile from the “Document Service Management” codeunit to upload the document into the Sharepoint.
  • If document uploaded successfully then will capture the shared URL via coding and send the email notification to the concerned users.
  • See the below screenshot of the existing processes.
  • In the extension I have used 2 more fields from “Document Setup” to more generic, you can add these two fields in any standard/custom setup table as shown below screenshot.
Document Setup
Document Setup
  • See the below snaps for the Document Attachment extension with “Upload & Share” action.
Document Attachment Details Ext 01
Document Attachment Details Ext 01
Document Attachment Details Ext 02
Document Attachment Details Ext 02
Document Attachment Details Ext 03
Document Attachment Details Ext 03
Document Attachment Details Ext 04
Document Attachment Details Ext 04
Document Attachment Details Ext 05
Document Attachment Details Ext 05

Results:

  • Open the Business Central Client and navigate to the item Card as shown below screenshot.
Item Card
Item Card
  • Open the Document Attachment Details page to Upload & Share the document.
  • Click on “Upload & Share” action and enter the recipients email ids and click on OK button as shown below screenshot.
  • After clicking the OK button, document will be uploaded into the SharePoint and an email send to the recipients.
Item Card - Share Attachment
Item Card – Share Attachment
  • To verify Email notification check the recipients email as shown below screenshot.
Email Notification
Email Notification
  • To verify Uploaded document check the Sharepoint as shown below screenshot.
Upload into the SharePoint
Upload into the SharePoint

To upload the files into specific folder like Customer, Sales Order or related Table, or if you want to manage your all documents in NAV / Business Central then VLC Solution has a great Apps /Add-ons called “VLC Document Management” which are available for NAV & Business Central.

For today that’s it, Thank you for reading.
Feel free to share your opinion on the below comment box.