Skip to main content

Posts

Showing posts from October, 2022

Export to Excel in Microsoft Dynamics 365 Business Central

Hi folks, In this article we will see how we can export data using Excel Buffer table in Excel format. Here, i am using the Excel Buffer as a temporary table to store data from master table to Buffer table on temporary basis and then write it to Excel file. Step-(1) Based   on the data format and columns, create a new Procedure/function on Codeunit to export data and download it in excel file. Codeunit 50002 "Export to Excel" {     trigger OnRun ()     begin     end ;     procedure ExportSalesHeaderInfo ()     var         TempExcelBuffer: Record "Excel Buffer" temporary ;         RecSalesHeader: Record "Sales Header";         FullAddress: Text ;     begin         RecSalesHeader . Reset () ;         TempExcelBuffer . Reset () ;         TempExcelBuffer . DeleteAll () ;         TempExcelBuffer . NewRow () ;         TempExcelBuffer . AddColumn ( RecSalesHeader . FieldCaption ( "No." ) , false, '' , true, false, false, '' , TempE

Import Excel file using Excel Buffer in Business Central

Hi Readers,  In Last article we have seen how we can import data (.csv format) in Business Central. In this article we will see how we can  Import Data (Excel format - .xlsx)  in Microsoft Dynamics 365 Business Central. Here i am using Excel Buffer as a record variable to read data from Excel file for temporary basis and then will store it to Master/required table. Let us take a scenario to Import Excel file to Employee Table. Step-(1)  First analyze the format/ structure of the csv data file as shown below: Step-(2)  Secondly based on the data format and columns, create a new Procedure/function on Codeunit to choose and import file using the dialog box to read the data. Codeunit 50001 "Excel Buffer Import" {     trigger OnRun ()     begin     end ;     var         TempExcelBuffer: Record "Excel Buffer";     local procedure ReadExcelSheet ()     var         FileName: Text [ 100 ];         SheetName: Text [ 100 ];         UploadExcelMsg: Label 'Choose the

How to Use .Net/DotNet Variables in Business Central : OnPremise

Hi Guys, In this blog we will see how we can define .NET variables in Microsoft Dynamics 365 Business Central. NOTE:-   .NET Interoperability is only available on-premise. If you want to use this functionality, you must set the   "target": "OnPrem"   in the   app.json   file. For more information, see   JSON Files . Alternatively you can use services such as Azure Functions to call into .NET dlls from AL, which will also work online. For online training, see  Use Azure Functions with Dynamics 365 Business Central . By default, compiler only knows about the location of the mscorlib assembly. By following step we can define any compatible assembly by providing the compiler with a path to the assembly's containing folder: Step-(1) Open Visual Studio Code and then go to Settings and search for Assembly Probing Paths to define referenced .NET assemblies: "al.assemblyProbingPaths": [     "./.netpackages",     "c:/Windows/assembly/",