Wednesday 4 September 2019

How to add progress bar window in D365 BC (Dynamics NAV)

When running the report everyone will be curious to know how long the report might run.
To track on at which level the report is processing the records we can run a progress bar in the foreground to have a better clarity of it.

Progress window can be displayed using the Open function of Dialog datatype.

Syntax:
Dialog.OPEN(String [, Variable1],...)

Few string parameters that can be considered in displaying progress bar:

1. Use a backslash (\) to start a new line.
2. Use number signs (#) to insert variable values into the string.
3. Place the number signs where you want to substitute the variable value.
4. Place a number in the part of the string where a variable value will be substituted

(Example, #1####) or (@1@@@@) to be able to reference this field for updating.

5. If you use @ characters instead of # characters, then the variable value is used as a percentage and both the percentage and a progress indicator are displayed. The percentage value that is displayed is the percentage of the variable value from 0 to 9999.



In OnPreDataItem initialze the following values.

--OnPreDataItem--

Window.OPEN('Processing data... #1################### @2@@@@@@@@@@@@@\');
NoOfRecs := COUNT;
NoOfRecsProgress := NoOfRecs DIV 100;
Counter := 0;
NoOfProgressed := 0;
TimeProgress := TIME;


In OnAfterGetRecord you can write the code(all variables of type integer except TimeProgress).


--OnAfterGetRecord--

//Do some processing
.
.

Counter := Counter + 1;

IF (Counter >= NoOfRecsProgress) OR (TIME - TimeProgress > 1000) THEN BEGIN
  NoOfProgressed := NoOfProgressed + Counter;
  Window.UPDATE(1,Custname); //this code will update the customer name at the control1
  Window.UPDATE(2,ROUND(NoOfProgressed / NoOfRecs * 10000,1)); //this will update the progress bar
  Counter := 0;
  TimeProgress := TIME;
END;


--OnPostDataItem--

Window.Close;

7 comments:

  1. It's really helpful thanks for sharing. Are you looking for dynamics nav support

    ReplyDelete
  2. Thank you for this post, it helps a lot for the former Dynamics NAV.
    A new version for Dynamics Business Central is available, just implemented it through these steps: Create Progress Bar on Business Central

    ReplyDelete
  3. Does this work in BC15 version and up? It doesn't look like the Microsoft team have made progress bar available for BC15 and up yet.

    ReplyDelete
  4. If you're reviewing your client's business credit report in India, it can tell you about their financial standing in the market. At CreditQ, you don't need to worry about how to check the business credit score of a business. You can review every vital point in the report.​ Visit us at CreditQ.

    ReplyDelete