Progress Dialogues in C/AL

by Nov 26, 2018C/AL Language

Home 9 Development 9 C/AL Language 9 Progress Dialogues in C/AL

One of the most neglected things I found on projects I have reviewed is progress dialogue for tasks, that run for more than a seconds. Although it is not always easy to estimate how long the task will run on production data, it is necessary to use progress dialogue as much as possible.

On the other hand, the badly designed dialogue could lead to major performance issues, so it is crucial to know how to work with dialogues.

Example

Let’s start with how dialogues are created. In C/AL language, dialogues are created using Dialog data type variable. From all functions that are defined for the Dialog data type, we use

  • OPEN() function to open a new dialogue. It has one required parameter – text of the dialogue that could have placeholders to show a value from the UPDATE function or percentage value.
  • UPDATE() to update the value of the dialogue. It has two parameters, the first one that specifies field we want to update (the number is defined as an order of the placeholders in the text that was used as a parameter for OPEN function). The second one specifies the value of the placeholder. If the function is called without any parameter, it just updates the dialogue, and so the application is in responding state (if we do not use UPDATE function and the loop took some time, the application just froze and the user may be notified about unresponding application).
  • CLOSE() to close the dialogue.

So the easiest dialogue could be created with only these three lines. Before the loop, open the dialogue, update it in each run of the loop and once the loop is exited, close the dialogue (see the code below).

 Local variables: 
   DialogVar (Dialog)
   MyRecord (Record of any table)
 --------------------
 Code:
   DialogVar.OPEN('My own text');
   REPEAT
     DialogVar.UPDATE();
   UNTIL MyRecord.NEXT < 1
   DialogVar.CLOSE();

We created a basic example of how to use progress dialogues. HOWEVER, this approach is really not ideal, and in loops with thousands of records, the impact on the performance will be significant.

The next article will describe how to develop performance-optimized progress dialogues and how to avoid some of the classic problems.

Recent Articles from the category

C/AL + AL: SetAutoCalcFields

SetAutoCalcFields is very similar method to CalcFields method. The only difference is that CalcField is run on the records already loaded from the database. On the other hand, SetAutoCalcFields is set before the records are loaded from the database. Although it can be...

read more

C/AL + AL: CalcFields

CalcFields is a method to calculate the FlowFields in a record. Flowfields are special fields (virtual) that are not stored physically in the database/table. Standard fields are loaded once the record is retrieved from the database. However, as the flowfields are...

read more

Optimized Progress Dialogues in C/AL

In the previous articles (see here) we discussed how to build standard progress dialogue in C/AL language. However, as mentioned at the end of the article, this way is definitely not applicable to a production environment due to the performance issues. In this...

read more

Sign Up for News

Certifications

Highest certification
Microsoft Data Management and
also in D365 Business Central

Microsoft Certified: Dynamics 365 Business Central Functional Consultant Associate

See other certifications here