Global variable loosing value?

wilk_u
Member Posts: 94
Hey, I'm still learning this..
I defined a global variable in codeunit, assigned it a value in one function of that codeunit when launching a form, and in after validate trigger on that form i want to launch another function form that codeunit where i want to use value of my global variable, but its empty.
What's going on exactly? Only direct assignment operation on that variable is when I assign it a value in first function.
Regards.
I defined a global variable in codeunit, assigned it a value in one function of that codeunit when launching a form, and in after validate trigger on that form i want to launch another function form that codeunit where i want to use value of my global variable, but its empty.
What's going on exactly? Only direct assignment operation on that variable is when I assign it a value in first function.
Regards.
0
Comments
-
I have created new codeunit with 2 functions
set and get
Set()
Num := 1000;
Get()
MESSAGE('%1',Num);
Num is a global variable of type integer..
Created new form and called Set function onOpen form.
Added a text field and called Get function OnAftervalidate of that field
message showed 1000
I didnt have any problem..0 -
-
wilk_u wrote:I defined a global variable in codeunit,mohana_cse06 wrote:Num is a global variable of type integer..0
-
Maybe I'll be more specific
Function executes after pressing button.
Codeunit.Function(GivenRec);
user selects record and then presses button.
It operates on gl entries.
Function goes like this:
table gl entry has additional field lests say AppID
if givenRec.Apply ID = ''
then CurrGLEntry SETRANGE(givenRec.EntryNo)
ELSE
currGLEntry.SETRANGE(givenRec.Apply ID)
//my global variable is AppID Code
AppID := givenRec.Apply ID;
I also tried to create another global variable TempEntry And Tempentry.TRANSFERFIELDS(CurrGLEntry);
to get Apply ID form it.
Then
FORM.RUNMODAL(Form,CurrGlEntry);
//
I checked in debugger, it sets correctly a value to AppID or TempEntry. But when i try to use these values they are empty.
Please help..0 -
...aaaand, where you try to get this value?-Mihail- [MCTS]0
-
In another function in that codeunit
Function2()
IF AppID <> comparedWithSth THEN...
and here that value appears as empty0 -
i am guessing you have declared your codeunit in the form too, and are trying to read the variable from there. You have to realise that by default, every time you declare a variable of your codeunit, it will be a seperate instance ! Either set the "single instance" property of the codeunit to "yes", or make function in the form you want to run to pass the values.0
-
You may be right if i understand You correctly.
I declared codeunit in form as global variable, and trying to execute functions from codeunit. Then i have empty values. So You say to declare single instance codeunit? I heard its not safe.. Is that right?
Regards.0 -
[Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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