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.

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.

Preview Environment for Business Central 2022 Wave 1 (BC20)

So with new year major version of business central is about to release and in context of that Microsoft released preview version of business central 2022 Wave 1 (BC 20). This preview version only possible to create for Sandbox and non production environment.

How to get this preview environment to get the hands on the new release

On the cloud version of business central one can create Sandbox as below for preview version

This preview version available on docker also.

For Docket Artifacts user following PowerShell command.

Get-BcArtifactUrl -storageAccount BcPublicPreview -country <country> -type <type>

To understand more about the features of BC20 you can visit here

Stay tuned for more on this version