Force progress bar in X++

Force progress bar in X++

There are several standard, best practice approaches to showing your user a wait indicator. Such as startLengthyOperation, SysOperationProgress, or even more creative approaches such as a manual Dialog run/close with various options for detach/modal.

However, I found come across many scenarios where these indicators are never shown to the user, depending on the scenario. Most recently, this occurred during a 5-10 second executeQuery. The standard "please wait while..." did not show, but form controls were unresponsive. Trying any of the approaches above never rendered anything to the user. I suspect this was caused by how the kernel is handling threads and updating the user interface, but this is only a guess.

A reliable workaround I have found seems to interrupt the default kernel processing to get a dialog displayed before the lengthy process starts. It will then close once form is responsive again. Note the "time elapsed" will never update on this control if you are using it for this workaround. In the example below, waitForSomething should only take one millisecond to run, but it displayed the entire length of the ExecuteQuery, which is the ideal behavior for this use case.

Step 1: create a dummy method with wait.

public static void waitForSomething(container _con)
{
     sleep(1);
}        

Step 2: call this method with SysOperationSandbox:

...

SysOperationSandbox::callStaticMethod(classNum(yourClass), staticMethodStr(yourClass, waitForSomething), conNull(), "Loading data...");

...
        

And you should get a dialog similar to this:





要查看或添加评论,请登录

Michael Schiermeyer的更多文章

  • AWS authentication in X++ for Vendor Central & others

    AWS authentication in X++ for Vendor Central & others

    The authentication step to AWS is rather complicated. A client had asked me to code the authentication step and they…

  • Default batch retry to 0

    Default batch retry to 0

    Microsoft introduced batch retry in 2021. This causes many unexpected results covered in many other articles.

    2 条评论
  • Refresh certificates on onebox dev machines

    Refresh certificates on onebox dev machines

    If you follow the onebox VHD setup, you have had to use the self signed certificate for a few years now during setup:…

    3 条评论
  • D365 SSRS Checkboxes using wingdings

    D365 SSRS Checkboxes using wingdings

    This article is more of a reminder that this is an option when developing SSRS reports in d365. In my twelve years of…

    1 条评论
  • Server certificates and production D365fo

    Server certificates and production D365fo

    Many integrations require certificates to authenticate the identify of the caller, in this case D365fo. Most…

    2 条评论
  • D365fo custom dimension defaulting in segmented entry controls

    D365fo custom dimension defaulting in segmented entry controls

    The below outlines how to code a custom dimension defaulting logic directly into the segmented entry controls such that…

  • D365fo join table as csv column in view/data entity

    D365fo join table as csv column in view/data entity

    Below is some sample code for joining a table to a view as a calculated field. Useful when you have data represented as…

社区洞察

其他会员也浏览了