Saving Reports to a company's SharePoint/OneDrive using AL

Hello, first time poster here.

As the title states I’m wondering if there is any way that you might know of to generate reports from Business Central (Cloud Hosted) then export them as PDF’s to our companies SharePoint/OneDrive. I want this solution to be entirely programmatic, using Business Central AL code, and I don’t want the file to be moved to a folder restricted/controlled by one user.

Happy to provide any additional context or clarification, thank you in advance.

Hi @nouh,

Wellcome to DUG!!!

I’ve never used Onedrive, but I’ve used Azure Blob Storage and Sharepoint to save files from BC.

Search for objects (there are tables, codeunits and other types) that contain “sharepoint” and “abs” in Microsoft System Application:

Type Id Name
Table 9043 ABS Container Content
Table 9044 ABS Container
Codeunit 9042 ABS Operation Payload
Codeunit 9043 ABS Helper Library
Codeunit 9044 ABS Format Helper
Codeunit 9045 ABS Web Request Helper
Codeunit 9046 ABS URI Helper
Codeunit 9047 ABS Optional Parameters
Codeunit 9048 ABS HttpHeader Helper
Codeunit 9049 ABS HttpContent Helper
Codeunit 9050 ABS Operation Response
Codeunit 9051 ABS Client Impl.
Codeunit 9052 ABS Container Client
Codeunit 9053 ABS Blob Client
Codeunit 9054 ABS Container Content Helper
Codeunit 9055 ABS Container Helper
Enum 9042 ABS Blob Access Tier
Enum 9043 ABS Blob Public Access
Enum 9044 ABS Block List Type
Enum 9045 ABS Blob Expiry Option
Enum 9046 ABS Rehydrate Priority
Enum 9047 ABS Blob Type
Enum 9048 ABS Operation
Enum 9049 ABS Lease Action
Enum 9050 ABS Blob Resource Type
Table 9100 SharePoint File
Table 9103 SharePoint List Item
Table 9104 SharePoint List Item Atch
Table 9105 SharePoint List
Table 9106 SharePoint Folder
Codeunit 9100 SharePoint Client
Codeunit 9101 SharePoint Client Impl.
Codeunit 9102 SharePoint List Item Atch.
Codeunit 9103 SharePoint List Item
Codeunit 9104 SharePoint List
Codeunit 9105 SharePoint Folder
Codeunit 9106 SharePoint File
Codeunit 9107 SharePoint Http Content
Codeunit 9108 SharePoint Operation Response
Codeunit 9109 SharePoint Request Helper
Codeunit 9110 SharePoint Uri Builder
Codeunit 9111 SharePoint Diagnostics
Codeunit 9142 SharePoint Auth.
Codeunit 9143 SharePoint Auth. - Impl.
Codeunit 9144 SharePoint Authorization Code
Codeunit 9145 SharePoint Client Credentials
Interface 0 SharePoint Authorization
PermissionSet 9100 SharePoint API - Objects
PermissionSet 9150 SharePoint Auth. - Objects

Here you have a good point to start for Sharepoint: Dynamics 365 Business Central: Microsoft SharePoint Connection Setup page (Open Excel in Sharepoint and OneDrive) | Dynamics 365 Lab

And here a point to start for ABS: How to connect to Azure Blob Storage using AL - Mercurius IT

@pjllaneras thank you for pointing me in the right direction!

To whoever stumbles across this post looking for their own solution:

I ended up going with the built in SharePoint integration code units in BC most things you want to do with SharePoint in BC can be done with these code units:

https://learn.microsoft.com/en-us/dynamics365/business-central/application/system-application/codeunit/system.integration.sharepoint.sharepoint-auth. (yes this link ACTUALLY ends with a period and breaks the linking so just copy and paste it yourself)

I used the authentication functions to establish the connection between the 2 platforms then used that to initialize the SharePoint client code unit and this is where most of your procedures can come from.

I won’t be able to share any code (for obvious reasons) but feel free to reach out if you have any questions.