Exchanging data between a form and a code-unit

tvandongen
Member Posts: 78
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).
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).
0
Comments
-
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
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions