Simple dialog page to input a number.

thomastthomast Member Posts: 102
Hi Guys,

Does anyone know how to make a very simple dialog box where the user can input a number and click OK?

I'm looking for something like the STRMENU function but where the user can input a number into a field - the value should then be brought back to the process which envoked it. Maybe it is possible to make a page which does not sit on top of a source table?

Thanks :)

Answers

  • mdPartnerNLmdPartnerNL Member Posts: 802
    Dialog.Input(value);
  • VerndroidVerndroid Member Posts: 18
    Create a page of type "ConfirmationDialog". Then create a variable to handle your input and place that as a field on the page.

    Create a public function on the page that returns the variable used in your input field.

    Something like this can then be done from C/AL:
    Page:
    OBJECT Page 50000 ConfirmDialog
    {
      OBJECT-PROPERTIES
      {
        Date=24-11-15;
        Time=09:29:52;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        PageType=ConfirmationDialog;
      }
      CONTROLS
      {
        { 1160040000;;Container;
                    Name=Testing input;
                    ContainerType=ContentArea }
    
        { 1160040001;1;Field  ;
                    CaptionML=ENU=Enter a number between 1 and 100;
                    SourceExpr=NumberToEnter }
    
      }
      CODE
      {
        VAR
          NumberToEnter@1160040000 : Integer;
    
        PROCEDURE ReturnEnteredNumber@1160040000() : Integer;
        BEGIN
          EXIT(NumberToEnter);
        END;
    
        BEGIN
        END.
      }
    }
    

    Codeunit
    OBJECT Codeunit 50000 Test Dialog
    {
      OBJECT-PROPERTIES
      {
        Date=24-11-15;
        Time=09:34:10;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                ConfirmDialog.LOOKUPMODE(TRUE);
                IF ConfirmDialog.RUNMODAL = ACTION::Yes THEN
                  MESSAGE(FORMAT(ConfirmDialog.ReturnEnteredNumber));
              END;
    
      }
      CODE
      {
        VAR
          ConfirmDialog@1160040000 : Page 50000;
    
        BEGIN
        END.
      }
    }
    
    
  • VerndroidVerndroid Member Posts: 18
    Dialog.Input(value);

    Won't work in RTC. Input is deprecated.
  • thomastthomast Member Posts: 102
    Hi Guys - the answer is to use a dotnet variable as described here:

    http://saurav-nav.blogspot.co.id/2014/09/discontinued-component-nav-2013-later.html
  • VerndroidVerndroid Member Posts: 18
    edited 2015-11-25
    Sry. In my book that is certainly not the answer. You may find that to be the best choice in your particular scenario but a better way (IMO ofc) is absolutely to use either a confirmationdialog type page or even better probably a pagetype::StandardDialog. StandardDialog page will give you and OK/CANCEL button and from a page you can do database interaction and all the regular stuff that NAV lets you do. You can't do that using a dotnet variable.
Sign In or Register to comment.