How To assign instance of Codeunit Variable.
lakshman
Member Posts: 44
Hi All,
can We assign one codeunit variable the instance of another codeunit variable.
please Suggest me.
can We assign one codeunit variable the instance of another codeunit variable.
please Suggest me.
0
Comments
-
Waldo wrote:Is transfers the values of the global variables of the codeunit. That could be the reason, no :-k ?
:? it is what i thought...but maybe i've done something wrong because it doesn't transfer global variables...
i've done this:cu.FNTGetParTest; cu := cu2; cu2.FNTGetParTest;
and in cu and cu2 .fntgetpartest there is:Par1 := Par1 + 100; Par2 := Par2 + 200; locpar := locpar + 555;
debugging it, when cu2.fntgetpartest is called, par1 and par2 have 0 value...am i missing something? :-k0 -
Hi All,
Thanks for your Reply.
I read one pdf file like below
Codeunit Assignment:
Codeunits can be treated as objects − one codeunit variable can be assigned to another codeunit variable, which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables
But i dont know how to assiagn one codeunit variable to another coudeunit variable thats why i posted it.0 -
And it's important how it's stated.
It's not how we thought: copying over the values of the variables. It's literally how it's stated: "...which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables ".
After assignment,
if changing a variable in CU1, it'll be changed in CU2 as well. It is a reference to the same thing.
So now I wouldn't know anymore why this would be useful.. :-k0 -
Me too. In my NAV-life, I have written a lot of (kriki-)code but I don't remember to have used this possibility once. :-kWaldo wrote:So now I wouldn't know anymore why this would be useful.. :-kRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:
Me too. In my NAV-life, I have written a lot of (kriki-)code but I don't remember to have used this possibility once. :-kWaldo wrote:So now I wouldn't know anymore why this would be useful.. :-k
This is very useful when you are posting and need to pass CU 22 or CU 12 to your own functions. These codeunits keep track of variables e.g. LastEntryNo. etc.
So if you are inserting additional Item journal line entries or GL Entries, you can use the variable that is used in CU 80 or 90.
Btw I've used this once and worked out well.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

