Inkey Solution Logo
banner

Blogs

How to Create Progress Indicator in Business Central using AL Code

, December 12, 2023 2114 Views

If you want to know how to create a progress indicator in Business Central using AL Code, look no further. This blog will teach you how.

A progress indicator is a useful feature that lets the user know how much of a long-running process has been completed and how much is left. A progress indicator can also display a percentage value and a progress bar to visualize the progress.

So, lets jump right in starting with prerequisites.

Prerequisites

  • Access to a Dynamics 365 Business Central instance.
  • Basic knowledge of AL (Application Language) code.
  • Visual Studio Code with AL Language extension installed.

Requirement

When there is a process in Business Central that takes too long to execute you can add a process indicator to show the user how much of it is left.

Solution (Implementation Steps)

To create a progress indicator, we will use the Dialog data type,

Progress Indicator in Business Central

and its methods, such as Open,

Progress Indicator in Business Central

Update,

Progress Indicator in Business Central

The Dialog data type allows us to create dialog windows that can display text and variables and update them dynamically. We will also use the Sleep function to simulate some processing time.

The basic steps to create a progress indicator are:

  • Declare a variable of type Dialog and some other variables to store the text and the progress value.
  • Use the Open method to open a dialog window with some text and a variable that will represent the progress value. Use number signs (#) to insert the variable value into the text and use @ characters instead of # characters to display the value as a percentage in a progress bar.
  • Use a loop to perform some processing and increment the progress value. Use the Update method to update the dialog window with the new value of the progress variable.
  • Use the Close method to close the dialog window when the processing is done.

Here is an example of AL code that implements these steps:

page 50100 INK_Progress_Indicator_Page
{
    Caption = 'Progress Indicator';
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;

    actions
    {
        area(Processing)
        {
            Action(Progress_Indicator_Action)
            {
                Caption = 'Progress Indicator';
                ApplicationArea = All;
                Image = Process;

                trigger OnAction()
                var
                    Progress: Dialog;
                    Counter: Integer;
                    Progress_Text: Label 'Processing 100 ............ @1';
                begin
                    Counter := 0;
                    Progress.Open(Progress_Text, Counter); //Progress dialog will open

                    repeat
                        //Put your processing code here  
                        Counter := Counter + 1;
                        Progress.Update(); //Progress dialog will be updated
                        Sleep(50);
                    until Counter = 0;

                    Progress.Close(); //Progress dialog will be closed
                end;
            }
        }
    }
}

Now, when you click on the action “Progress Indicator” you will see the progress dialog,

You can customize the text and the variable in the dialog window according to your needs. For example, you can use different labels for different languages, or use different variables for different processes. Also “Counter” variable is an integer so you can choose any number between its range which is -2,147,483,647 to 2,147,483,647.

You can also use the progress dialog on reports.

{
    Caption = 'Progress Indicator Report';
    UsageCategory = Administration;
    ApplicationArea = All;
    ProcessingOnly = true;

    trigger OnPreReport()
    var
    begin
        Clear(Counter);
        if not GuiAllowed then
            exit;
        Progress.Open(Progress_Text); //Progress dialog will open
    end;

    trigger OnPostReport()
    var
    begin
        //Put your processing code here  
        for Counter := 1 to 100 do begin
            Progress.Update(1, Counter); //Progress dialog will be updated
            Sleep(50);
        end;
        Progress.Close(); //Progress dialog will be closed
    end;

    var
        Counter: Integer;
        Progress_Text: Label 'Processing 100 ............ #1';
        Progress: Dialog;
}

Now when you run the report progress dialog will show up,

Conclusion

I hope this blog post was helpful for you to learn how to create a progress indicator in Business Central using the Progress dialog. If you have any questions or feedback, please leave a comment below.


ATM Inspection PowerApp to ease ATM inspection and report generation process.
https://www.inkeysolutions.com/microsoft-power-platform/power-app/atm-inspection

Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/drag-and-drop-listbox

Comply your Lead, Contact, and User entities of D365 CRM with GDPR compliance using the GDPR add-on.
https://www.inkeysolutions.com/microsoft-dynamics-365/dynamicscrmaddons/gdpr

Create a personal / system view in Dynamics CRM with all the fields on the form/s which you select for a particular entity using the View Creator.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/view-creator

mm

Inkey

INKEY is your solution partner.
Our focus is to deliver you in-time intelligent innovative solutions ("key") for the problems in hand. Maintaining a quality standard right from the inception of a project is our top most priority.

Our team of talented professionals will execute your projects with dedication and excellence. We take ownership and accountability for the effort that goes into meeting our client’s needs.

Years of experience and proven success of delivering innovative custom solutions.

More posts by

Leave a Reply

Your email address will not be published. Required fields are marked *

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Drop file here

Would you like to digitize your business and put it on the cloud?
Do you need clear, concise reports for your organization?