How is possible to return a value from a Form into a Codeun?

efassetta
Member Posts: 53
Hello, i need help. I have a Codeunit that runs a Form (with Form.RUN function). On this Form i have a text variable to modify. Then when i close the form, i need this value in the Codeunit.
How can i do??
Thank's in advance.
How can i do??
Thank's in advance.
0
Comments
-
global variable:
frmMyForm Form "My Form"clear(frmMyForm); IF frmMyForm.RUNMODAL = ACTION::LookupOk THEN BEGIN MESSAGE('%1',frmMyForm.GetReturnValue()); END;
Of course you have to create a lookup-ok button if you don't have it(copy the Ok button from Form 4) and if you add the cancel-button, you can also cancel the action and you wont see the message.
In the form, you have to create this function:GetReturnValue() : (return-type is the type of your variable) BEGIN EXIT("My Variable"); END;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The previous example works fine in case of a form based on a table.
The following code is in case you don't have a table:OBJECT Form 99000 The Form { OBJECT-PROPERTIES { Date=15/03/06; Time=18:53:51; Modified=Yes; Version List=; } PROPERTIES { Width=9790; Height=6710; TableBoxID=1000000000; } CONTROLS { { 1000000003;CommandButton;2530;5940;2200;550; HorzGlue=Right; VertGlue=Bottom; Default=Yes; PushAction=OK; InvalidActionAppearance=Hide } { 1000000004;CommandButton;4950;5940;2200;550; HorzGlue=Right; VertGlue=Bottom; Cancel=Yes; PushAction=Cancel; InvalidActionAppearance=Hide } { 1000000005;CommandButton;7370;5940;2200;550; HorzGlue=Right; VertGlue=Bottom; PushAction=FormHelp } { 1000000000;TextBox;4070 ;990 ;1700 ;440 ;SourceExpr=codText } { 1000000001;Label ;660 ;990 ;3300 ;440 ;ParentControl=1000000000 } } CODE { VAR codText@1000000000 : Code[10]; PROCEDURE GetReturnValue@1000000001() : Code[10]; BEGIN EXIT(codText); END; BEGIN END. } } OBJECT Codeunit 99000 The Codeunit { OBJECT-PROPERTIES { Date=15/03/06; Time=18:54:19; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN CLEAR(frmTheForm); IF frmTheForm.RUNMODAL = ACTION::OK THEN BEGIN MESSAGE('<%1>',frmTheForm.GetReturnValue()); END; END; } CODE { VAR frmTheForm@1000000000 : Form 99000; BEGIN END. } }
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
:oops:
there is also a how to for it : http://www.mibuso.com/howtoinfo.asp?FileID=7Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I think you covered all the bases =D>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