web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

how to read and save files from/into Sharepoint with X++

(0) ShareShare
ReportReport
Posted on by 45

Hello,

I'd want to import files (Excel) from Sharepoint and was wondering if there are any useful x++ documentations for working with files.

I'd want to do the following:
-Using x++, download a file(Excel) from SharePoint and extract data from it
-create folders In SharePoint.
-Place files in the sharepoint folder
-Generate a text file (.txt).

thank you.

I have the same question (0)
  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Maybe you could reuse existing functionality for this purpose. Document management and electronic reporting support SharePoint.

    For example, look at Docu::GetStorageProvider() (with DocuFilePlace::SharePoint). The provider is also used by ERFileDestinationSharePoint class.

  • Saoudi Hatem Profile Picture
    45 on at

    Thank u goshoom  

    I attempt to utilize them, but it's not that evident. Also I'd want to know where I can find any relevant information about working with files, as well as whether I need to use dotnet builtin packages.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Saoudi,

    You describe a process where a file is taken from SharePoint, convert it to another format an save it again in SharePoint. Tools like Power Automate and Logic Apps will do the job more easily with configuration instead of development in Dynamics 365.

  • Saoudi Hatem Profile Picture
    45 on at

    thank u Andre Arnaud de Calavon

    Because the customer does not want to operate with Power Automate or Logic Apps, I must use X++.

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    I'm not sure what you mean by dotnet builtin packages, but you'll indeed need .NET in some way. Either you'll utilize the Dynamics libraries that Microsoft uses, or you'll use SharePoint libraries directly, or you'll use libraries for HTTP communication.

    By the way, trying to avoid using existing Azure resources becomes less and less feasible. It will be wise if your customer learn how to use cloud resources rather then rejecting them. Not only that reiventing the wheel is expensive, but many things will become impossible, although they're rather easy if you utilize available tools.

  • Saoudi Hatem Profile Picture
    45 on at

    In case any one want to get a file from sharePoint U need to use the namespace Microsoft.Dynamics.Platform.Integration.SharePoint

    I wish this code help

    using SP = Microsoft.Dynamics.Platform.Integration.SharePoint;
    class SPclass
    {
        /// 
        /// Runs the class with the specified arguments.
        /// 
        /// The specified arguments.
        public static void main(Args _args)
        {
             System.UriBuilder builder = new System.UriBuilder("xxxxx.sharepoint.com/sites/mysite");
            str host = builder.Host;
            System.Uri uri = new System.Uri("https://xxxxxx.sharepoint.com/sites/mysite/_api/web/"   "GetFileByServerRelativeUrl('/sites/mysite/Documents partages/Fichier XLSX/IN/myfile.xlsx')/$value");
            str extId = xUserInfo::getExternalId();
            SP.SharePointProxy proxy = SP.SharePointHelper::CreateProxy(host,'/sites/mysite', extId);
            str token = proxy.AccessToken;
            SP.FileResults FileResults = new SP.FileResults();
            SP.FileContents File;
            
            
            
                
            if(SP.SharePointHelper::VerifyAuthentication(proxy))
            {
                //Method 1
                memoryStream = SP.SharePointHelper::GetFiles(proxy,"Documents partages/Fichier XLSX/IN","");
                System.Collections.IEnumerable results = FileResults.Results;
                var fileListEnumerator = results.GetEnumerator();
                while (fileListEnumerator.MoveNext())
                {
                    SP.FileResult fileResult = fileListEnumerator.Current;
                }
                //Method2
                File = SP.SharePointHelper::GetFileContents(proxy, Uri, true);
                
    
            }
              
        }
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans