Options

Simple request form

lzrlzr Member Posts: 264
I am trying to make a form that only asks the user for some text input, then quits.

The problem is the textbox need sourceexpression. But since I do not use any table I don't have a field to use as an expression.

Anyone know how to do?
Navision developer

Comments

  • Options
    AlbertvhAlbertvh Member Posts: 516
    Hi

    Define a global variable :D
    Albert
  • Options
    lzrlzr Member Posts: 264
    Did that but then it says something about

    "When the function is called, the minimum number of parameters should be used".

    What function? :)
    Navision developer
  • Options
    AlbertvhAlbertvh Member Posts: 516
    Hi
    How are you calling this form. Have you defined a function? :roll:
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    If all you need is some text entered by the user, you could also use a Dialog:
    Variables:
    ----------
    Name	     DataType	Subtype	Length
    dlgDialog	Dialog		
    txtInput	 Text		           30
    
    
    dlgDialog.OPEN('Enter your name #1#########');
    dlgDialog.INPUT(1,txtInput);
    dlgDialog.CLOSE;
    MESSAGE('Hello %1',txtInput);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    lzrlzr Member Posts: 264
    If all you need is some text entered by the user, you could also use a Dialog:
    Variables:
    ----------
    Name	     DataType	Subtype	Length
    dlgDialog	Dialog		
    txtInput	 Text		           30
    
    
    dlgDialog.OPEN('Enter your name #1#########');
    dlgDialog.INPUT(1,txtInput);
    dlgDialog.CLOSE;
    MESSAGE('Hello %1',txtInput);
    

    At this time I only need simple input but I might want to expand it later, thanks tho.
    Navision developer
  • Options
    lzrlzr Member Posts: 264
    Albertvh wrote:
    Hi
    How are you calling this form. Have you defined a function? :roll:

    I was planning on doing something like http://www.mibuso.com/howtoinfo.asp?FileID=7&Type=howto

    I am still pretty new to how these forms in Navision works so if you could be a little more clear about what I missed I would appreciate it. I want the text field to be empty and when a user enters a text and click ok it should return this text to the original form (or passing a value from the original form so that this subform can execute code itself)
    Navision developer
  • Options
    Soft_TodSoft_Tod Member Posts: 43
    Hi, I've done something similar.

    In the Main Form I call the Input Form modally, the user can enter some Text, chose OK or CANCEL and the Input Form close. The Main Form can pick up the Entered Text and process accordingly.

    From your description it sounds something like that.

    Here's the text file export of the two Forms (it's in a german Database so you probably need to change the locales into swedish before importing the textfile :D ):
    OBJECT Form 74000 MainForm
    {
      OBJECT-PROPERTIES
      {
        Datum=26.07.05;
        Zeit=12:32:38;
        Ge„ndert=Ja;
        Versions Liste=;
      }
      PROPERTIES
      {
        Width=7040;
        Height=1760;
      }
      CONTROLS
      {
        { 1000000000;CommandButton;330;990;2200;550 ;CaptionML=DEU=Get Input;
                                                     OnPush=VAR
                                                              frmInp@1000000000 : Form 74001;
                                                            BEGIN
                                                              frmInp.SetInputValue(1, g_sText);
                                                              IF (frmInp.RUNMODAL = ACTION::OK) THEN
                                                                 g_sText := frmInp.GetInputValue(1);
                                                            END;
                                                             }
        { 1000000001;TextBox;330  ;330  ;6490 ;550  ;Editable=Nein;
                                                     SourceExpr=g_sText }
      }
      CODE
      {
        VAR
          g_sText@1000000000 : Text[1024];
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 74001 InputForm
    {
      OBJECT-PROPERTIES
      {
        Datum=26.07.05;
        Zeit=12:24:04;
        Ge„ndert=Ja;
        Versions Liste=;
      }
      PROPERTIES
      {
        Width=7260;
        Height=1760;
      }
      CONTROLS
      {
        { 1000000000;TextBox;110  ;110  ;6930 ;550  ;SourceExpr=g_sInput[1] }
        { 1000000003;CommandButton;2420;880;2200;550;PushAction=OK }
        { 1000000004;CommandButton;4730;880;2200;550;PushAction=Cancel }
      }
      CODE
      {
        VAR
          g_sInput@1000000000 : ARRAY [20] OF Text[1024];
    
        PROCEDURE GetInputValue@1000000000(Idx@1000000000 : Integer) : Text[1024];
        BEGIN
          EXIT(g_sInput[Idx]);
        END;
    
        PROCEDURE SetInputValue@1000000001(Idx@1000000000 : Integer;DefaultText@1000000001 : Text[1024]);
        BEGIN
          g_sInput[Idx] := DefaultText;
        END;
    
        BEGIN
        END.
      }
    }
    
    

    I using an Array in the Input form to ensure future enhancements. Its also possible to set the default value in the Input Form.

    Lycka till
    It is impossible to make anything foolproof, because fools are so ingenious.
  • Options
    lzrlzr Member Posts: 264
    Soft Tod wrote:
    Hi, I've done something similar.

    In the Main Form I call the Input Form modally, the user can enter some Text, chose OK or CANCEL and the Input Form close. The Main Form can pick up the Entered Text and process accordingly.

    From your description it sounds something like that.

    Here's the text file export of the two Forms (it's in a german Database so you probably need to change the locales into swedish before importing the textfile :D ):

    I using an Array in the Input form to ensure future enhancements. Its also possible to set the default value in the Input Form.

    Lycka till

    Vielen dank :)
    Navision developer
  • Options
    lzrlzr Member Posts: 264
    Omg, you know what I did wrong? I put a variable name called "message" in my form :oops:
    Navision developer
Sign In or Register to comment.