Exchanging data between a form and a code-unit

tvandongentvandongen Member Posts: 78
edited 2004-11-20 in Navision Attain
I need to make a form where I can pass parameters to (that's no problem) and that can give the result back to the code-unit. The form should look exactly like the confirm dialog form of Navision, so I just want to know if the user pressed the OK button or the Cancel Button.
If I call the form with form.runmodal it's not a problem, but I then get a NF message that it is not allowed to use FORM.RUNMODAL with writing transactions (I don't write anything in the form, just displaying a message). The only solution for that message is putting a COMMIT statement just before the FORM.RUNMODAL command, and I don't like to use COMMIT, because I then have a problem if the user pressed Cancel.
If I use FORM.RUN then I don't get the result of the pressed button back.

Does anybody know a way to solve this ?

PS. I'm using NF 2.60. I can't use the standard confirm dialog box, because it is not possible to change the position and the size of the box, and it should be used on a portable barcode scanner with citrix (so I have only a small screen).

Comments

  • RobertMoRobertMo Member Posts: 484
    1. You should define your form as global in cu.
    In form you are calling, you should add 2 functions like "SetParms(parm1,parm2...)" and "GetParms(VAR result1, VAR result2...)".

    In "SetParms" you just assign sent parms to globals on form:
    FormsGlobalParm1 := parm1;
    FormsGlobalParm2 := parm2;

    In "GetParms" you assign the result to a return value. Or if you want more results with one call, you can use VAR parms for the function:
    result1 := FormsGlobalResult1;
    result2 := FormsGlobalResult2;

    BUT!
    More important is that you are in the middle of transaction and if you call your form like form.RUN, your transaction will contiunue and might end before you press ok or cancel. and you can select parent form without closing or choosing an action on child form. anyway the behaviour is very unpredictable.

    RUNMODAL is not allowed within transaction, because it pauses code execution and waits for a user answer (who may be on coffee break) while tables are locked.

    The best for you would be to use runmodal, but to put it earlier in code. try to ask the question before transaction began. before INSERT or MODIFY - or even before FIND, if you use this record as base of your changes (someone might change your rec after you have read it and waited for an answer) - or you use explicit locking before reading...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.