How to export data using TextBuilder in Business central.

Today we will see how we can data from business central table using new data type Text Builder.

To check how this data type work build small program as below which pick up data from customer table and export the data in text file.

pageextension 50101 CustomerMasterExtension extends "Customer List"
{
    actions
    {
        addlast(General)
        {
            action(DataExport)
            {
                Caption='Data Export to Text';
                ApplicationArea=All;
                PromotedCategory=Process;
                Promoted=true;
                Image=ExportDatabase;
                trigger OnAction()
                var
                CustomerMaster :Record Customer;
                Tempblob:Codeunit "Temp Blob";
                TextFileBuilder :TextBuilder;
                FileName:Text;
                InStreamData:InStream;
                OutStreamData:OutStream;
                begin 
                    FileName:='CustomerData.Txt';
                    TextFileBuilder.AppendLine('Customer No'+','+'Customer Name'+','+'Balance');
                    If CustomerMaster.FindSet() then repeat
                        CustomerMaster.SetAutoCalcFields(CustomerMaster.Balance);
                        TextFileBuilder.AppendLine(CustomerMaster."No."+','+CustomerMaster.Name+','+Format(CustomerMaster.Balance));
                    until CustomerMaster.Next()=0;
                    Tempblob.CreateOutStream(OutStreamData);
                    OutStreamData.WriteText(TextFileBuilder.ToText());
                    Tempblob.CreateInStream(InStreamData);
                    DownloadFromStream(InStreamData,'','','',FileName);
                end;
            }
        }
    }
}

If you look at the above code it is taking required data from customer table and export the data in text file as below.

To get more insight of data type have a look at MS documentation from below link

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/textbuilder/textbuilder-data-type

Hope this will help you.

Stay tuned for more.

Advertisement

How to change Customer Name on Open Sales Order in business central

With the release business central Wave 1 2022 lot of new features has been added to improve the user interaction with application.

This feature is small improvements in business central which allows to changes the name of customer on open sales document. This change of name will be applicable for that document only. This change of name is controlled by setup on sales & receivables setup.

Lets see how this setup works now on sales order

  1. If this setup is not enabled on Sales & Receivable setup .Try to change name on sales order and it shows following message

This message states that if you trying to change the customer name then master not found the record then asking whether like to create new record or if you existing customer with new name then select that customer.

2. If this setup is enabled in Sales & Receivables setup. Try to change name on sales order.

Now it allows to change the name on sales order

Hope this will help

Stay tune for more….

How to define multiple layouts for report in Business Central

With the release of business central V20 lot of new features are introduced and one of the features in you can define multiple layouts for reports while developing

In earlier days we are defining multiple layouts as below.

Now with the new release new rendering section is added while creating report in AL development

In the above rendering section we can define multiple layout as below

After compilations of report we can see the layout is created as below

Isn’t that cool features for layout

This features is available for Runtime 9.0

Hope this will help you..

Stay tuned for more.

Business Central Wave 1 2022 Released

With the new dawn of 1st April Microsoft released Business Central Wave 1 2022.

The product DVD will be downloaded from following URL

Business Central Wave 1 2022

Few features of Business Central you can visit this link

Business Central Wave 2 2022 Features

Stay tuned for more detail.