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.
- Microsoft office 365 SharePoint
- Microsoft Dynamics 365 Business Central
- Microsoft Visual Studio Code
- 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/
- 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.
- Choose the type of site you would like to create as shown below screenshot.
- Enter the Site Name, Site Description and Click on Next button as shown below screenshot.
- If you would like to add additional owners then add members or else click on Finish button as shown below screenshot.
- 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.
- Now Share point is ready, next step to configure the connection in the business central which is described in Step 2.
- Login to the Business Central Client and click on search button and choose the related link as shown below screenshot.
- 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.
- 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.
- After setup the password test the connection by clicking on Test Connection action as shown below screenshot.
- 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.
- 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.
- 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.
- See the below snaps for the Document Attachment extension with “Upload & Share” action.
- Open the Business Central Client and navigate to the item Card as shown below screenshot.
- 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.
- To verify Email notification check the recipients email as shown below screenshot.
- To verify Uploaded document check the Sharepoint as shown below screenshot.
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.