Hi
I want to automate the process of uploading an excel file to dynamics from a particular sharepoint location.
How to achieve this ?
Thanks
It was obvious the same topic. I have merged the questions to prevent any confusion on the status of both of them. Now it is one question again.
I doubt if ChatGPT is able to replace Dynamics 365 F&O developers. Can you tell what exact errors you get? When looking at the generated coding, it is using Dynamics 365 CRM references, and this is not importing data in Dynamics 365 F&O expense management.
Like mentioned above, you can use tools like Logic App or Power Automate. If you insist re-inventing the wheel using x++ coding, you will need to find examples in the application or on the internet.
You can create a LogicApp to periodically upload the files from SharePoint to Dynamics 365 Finance.
This post is a duplicate of community.dynamics.com/.../automate-process-for-upload-an-excel-file-from-sharepoint-to-dynamics ?
Hi
I want to automate the process of uploading excel from sharepoint to dynamics365 FO. This automation should trigger on a daily basis.
I got below solution from ChatGPT but getting few errors.
using Microsoft.Dynamics.AX.Framework.FileManagement; using Microsoft.Dynamics.AX.Framework.Services.Client; using Microsoft.Dynamics.AX.Framework.Services.OrganizationService; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; class RP_SharepointAutomate { static void uploadExcelToDynamics(Args _args) { // Set SharePoint and Dynamics 365 connection details str sharepointUrl = "https://your-sharepoint-site.sharepoint.com/sites/your-site"; str documentLibraryName = "Documents"; str dynamicsUrl = "https://your-dynamics-instance.api.dynamics.com"; str tenantId = "your-tenant-id"; str clientId = "your-client-id"; str clientSecret = "your-client-secret"; // Authenticate to SharePoint SharePointOnlineCredentials sharepointCredentials = new SharePointOnlineCredentials("your-username", "your-password"); System.Net.WebClient webClient = new System.Net.WebClient(); webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f"); webClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); webClient.Credentials = sharepointCredentials; str fileUrl = sharepointUrl "/" documentLibraryName "/" "your-excel-file.xlsx"; byte[] fileContent = webClient.DownloadData(fileUrl); // Authenticate to Dynamics 365 System.Uri dynamicsUri = new System.Uri(dynamicsUrl); System.IdentityModel.Tokens.ClientCredentials deviceCredentials = new System.IdentityModel.Tokens.ClientCredentials(); deviceCredentials.UserName.UserName = clientId; deviceCredentials.UserName.Password = clientSecret; Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext authenticationContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext("https://login.microsoftonline.com/" tenantId); Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult authenticationResult = authenticationContext.AcquireToken(dynamicsUrl, deviceCredentials); str accessToken = authenticationResult.AccessToken; // Connect to Dynamics 365 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy organizationServiceProxy = new Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy(dynamicsUri, null, deviceCredentials, null); organizationServiceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); organizationServiceProxy.HeaderToken = accessToken; // Upload the Excel file to Dynamics 365 Microsoft.Xrm.Sdk.Entity documentEntity = new Microsoft.Xrm.Sdk.Entity("annotation"); documentEntity.Attributes["filename"] = "your-excel-file.xlsx"; documentEntity.Attributes["documentbody"] = System.Convert::ToBase64String(fileContent); documentEntity.Attributes["mimetype"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; System.Guid documentId = organizationServiceProxy.Create(documentEntity); info(strFmt("Excel file uploaded to Dynamics 365 with ID %1", documentId)); } }
Please suggest a solution for this problem. Either through enhancement in this code or by providing new solution or approach.
Regards
I want to upload in Expense Management Module
This can be done using power automate to connect with SharePoint site and for uploading you can use F&O connector and connect with related data entity.
May I know where in D365FO you want to upload the excel files.
André Arnaud de Cal...
291,969
Super User 2025 Season 1
Martin Dráb
230,842
Most Valuable Professional
nmaenpaa
101,156