Dynamics Search Engine

Thursday, June 16, 2016

In Microsoft Dynamics AX 2012 how to get a progress bar to display the progress of a process or transaction by X++ code.

In Microsoft Dynamics AX 2012 how to get a progress bar to display the progress of a process or transaction by X++ code.

Applied on: Dynamics AX 2012 R3 CU8.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience
: AX programmers.
Assumption
: You are familiar with Dynamics AX 2012.

There are different ways to get a progress bar or update bar while a lengthy transaction or update is happening.
It’s always nice to give a progress bar to user for any lengthy manual operation so that gives user an indication like something is happening.
Below method is responsible to give a progress bar if you use it for any heavy or lengthy operation.

Option 1:

public static client SysOperationProgress showWaitDialog(str _text = "Extracting record for you, please wait...")
{
    #AviFiles
    SysOperationProgress waitDialog;

    waitDialog = new SysOperationProgress(1, true, strLen(_text));

    waitDialog.setCaption("Calculating value...");
    waitDialog.setTotal(100);
    waitDialog.setCount(1);
    waitDialog.setAnimation(#AviUpdate);
    waitDialog.setText(_text);

    return waitDialog;
}

The output is shown below.


To get the above shown output you need to create a method as shown above and call the method before your lengthy operation starts.
How to call?
I have a sample job here to call the method.




Option 2:

Add startLengthyOperation() before and after your lengthy operation code. A sample code is shown below with output. In this case you see a busy icon and system does not allow to do anything.







1 comment: