Skip to main content

Posts

Showing posts from 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 () ;         Temp...

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         ...

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/", ...

Import CSV file using CSV Buffer in Business Central

Hi Everyone,  In this article we will see how we can Import Data (CSV/Excel format) in Microsoft Dynamics 365 Business Central. Here i am using CSV Buffer as a record variable to read data from csv file for temporary basis and then will store it to Master table. Let us take a scenario to import CSV 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 "CSV Import" {     trigger OnRun ()     begin     end ;     procedure ImportEmployeeDetailViaCSVBuffer ()     var         csv_InStream: InStream ;         uploadResult: Boolean ;         csvFileName: Text ;         csvBuffer: Record "CSV Buffer";       ...

Run Customize Report in Place of Standard Report in Businss Central : Report Management

Hi Everyone, In this article we will see how we can run Customized report in place of standard Report using Report Management Codeunit. As we all know that sometimes we get the basic requirements from Client to do some minor changes in Standard Report. Accordingly, will see how we can do changes in standard report or Create custom report and then Run the custom report in place of standard Report. Step-(1) First we have to configure the new Report to replace it with Standard Report: As in this case i have already Customized Purchase Order (Report ID - 50100)  Report as show below: Step-(2) Now create a procedure & subscribe it to the OnAfterSubstituteReport   event , i.e, basically it will just replace the report specified by the ReportId with the newly created report as NewReportID parameter: codeunit 50100 "Substitute Report" {     [EventSubscriber (ObjectType :: Codeunit , Codeunit ::ReportManagement, 'OnAfterSubstituteReport' , '' , true, true ) ]...

Integration in Business Central & Read JSON Data and store in Table : Using Http

Hi Readers, In this article will see how we can create connection with external application using  HTTP and read the Json data & store it in business central. In this scenario, if i will enter the ID then it will fill all the related details by getting information from third party application. Step-(1) Firstly i have created the table and call the procedure on OnValidate trigger. table 50102 "User Details API" {     DataClassification = ToBeClassified;     fields     {         field( 1 ; ID; Integer)         {             DataClassification = ToBeClassified;             trigger OnValidate ()             var                 JsonReadAndWrite_CU: Codeunit "Json Write";             begin                 JsonRe...

How to Create & Download the Json in Business Central : Using Json Datatypes

Hi Experts, In this article i am learning & sharing with you guys that how to Create Json structure in Business Central. In this example, i am creating Json structure from Customer table and store that Json file in local system. Codeunit 50101 "Json Write" {     trigger OnRun ()     var         Customer_Rec: Record Customer;         JObject_Cust: JsonObject ;         JObject_Address: JsonObject ;         JArray_Address: JsonArray ;         JObject_PostingGroup: JsonObject ;         JArray_PostingGroup: JsonArray ;         RecTempBlob: Record TempBlob;         InStr: InStream ;         OutStr: OutStream ;         FileName: Text ;         Result: Text ;     begin         // Code to Create Json file Structure_Start ...