Variable to Codeunit

Hi all, I have created a form in which the user inserts his username and his password in order to approve an order. The codeunit that call the form can’t read the results of my test. What I have done: Create a form with 2 text box and two button (userid, pwd, Cancel, OK) Set the PushAction property of two button Check Username and pwd in the ONPUSH trigger of OK button In the Codeunit that call the form read RUNMODAL value and continue the execution … The problem is that when user push the OK button after the execution of my test (userid and pwd) continue closing the form and don’t stop code. I have tried with ERROR instruction but after message system close the form and codeunit read OK value. Can you help me??? [?]

Two things: 1. Do you use the command “IF FORMRUNMODAL(…) IN [ACTION::OK,ACTION::LOOKUPOK] THEN …”? 2. What is “PushAction” on your OK-button? Should be “LookupOk”.

Hi, Set property LookUpMode of the form to true. set property PushUpAction of your OK-Button to LookUpOk set property PushUpAction of your Cancel-Button to LookUpCancel declare variable userid, pwd as global on form DON’T check any input on the form Create a function in your form : function GetParam(var parauserid, var parapwd) parauserid := userid parapwd := pwd; end; modify codeunit to the following: if form.runmodal=action::lookupok then begin; form.GetParam(userid,pwd); // Now do checking of userid and passwort end else begin error(‘Input not valid’); end;

Yes Iuse the command “IF FORMRUNMODAL(…) IN [ACTION::OK,ACTION::LOOKUPOK] THEN …”? Pushaction is OK. Corrado

Hi Hans, thanks for your tip. But I don’t understand one thing: when I write “form.GetParam(userid,pwd)” in the codeunit system don’t find userid and pwd because are variables of form. How can i solve the problem? Thank

form.runmodal means the following : 1.) you have to define a varable form of type form and the ID of the form that should run 2.) you MAY NOT use formrunmodal(Form::“name of form”)

Yes, I do it. formCheckPassword is a variable of form type and NomeUtente and Password are globals of form The code in the codeunit is: IF formCheckPassword.RUNMODAL=ACTION::LookupOK THEN BEGIN formCheckPassword.getParam(NomeUtente,Password) END ELSE BEGIN ERROR(’’);

Sorry i figured out, that you may not use the variablename form because its allready defin

And so? What I have to do?

Solution as text export : !! It’s a german export of Navision 2.01 Perhaps you have to delete the lines with OBJECT-PROPERTIES OBJECT Form 50160 TEST { OBJECT-PROPERTIES { Datum=23.10.03; Zeit=17:52:30; Ge„ndert=Ja; Versions Liste=nolug; } PROPERTIES { Width=6820; Height=2970; LookupMode=Ja; } CONTROLS { { 1 ;TextBox ;4840 ;880 ;1650 ;440 ;SourceExpr=UserName } { 2 ;Label ;1430 ;880 ;3300 ;440 ;ParentControl=1 } { 3 ;TextBox ;4840 ;1540 ;1650 ;440 ;SourceExpr=UserPWD } { 4 ;Label ;1430 ;1540 ;3300 ;440 ;ParentControl=3 } { 7 ;CommandButton;4290 ;2200 ;2200 ;550 ;PushAction=LookupOK } { 8 ;CommandButton;1870 ;2200 ;2200 ;550 ;PushAction=LookupCancel } } CODE { VAR UserName : Text[30]; UserPWD : Text[30]; PROCEDURE GetParam@1(VAR paraName : Text[30];VAR paraPWD : Text[30]); BEGIN paraName := UserName; paraPWD := UserPWD; END; BEGIN END. } } OBJECT Codeunit 50042 TEST { OBJECT-PROPERTIES { Datum=23.10.03; Zeit=17:52:54; Ge„ndert=Ja; Versions Liste=nolug; } PROPERTIES { OnRun=BEGIN IF UserCheck.RUNMODAL=ACTION::LookupOK THEN BEGIN; UserCheck.GetParam(Name,PWD); MESSAGE('%1 %2',Name,PWD); END ELSE BEGIN ERROR('No Valid input'); END; END; } CODE { VAR UserCheck : Form 50160; Name : Text[30]; PWD : Text[30]; BEGIN END. } }

THANKS A LOT HANS!!!