How To pass parameters between objects (forms..) Revisited

Administrator
Member, Moderator, Administrator Posts: 2,506
How To pass parameters between objects (forms, reports, ...)? Revisited
http://www.mibuso.com/howtoinfo.asp?FileID=9
Discuss this How To here.
http://www.mibuso.com/howtoinfo.asp?FileID=9
Discuss this How To here.
0
Comments
-
It`s just what I was looking for since a long time now. One CodeUnit that does all the necessary work for passing Parameters. Thanks.0
-
I wanted to use this to store temporary records, but it loose all rows between code calling (after leaving runing code)
So it is useful only for simple variable types, or i do something wrong... dont know whatRobert Polz0 -
Robik wrote:I wanted to use this to store temporary records, but it loose all rows between code calling (after leaving runing code)
So it is useful only for simple variable types, or i do something wrong... dont know whati did something wrong
i used
Function GetRec(VAR Rec Temporary)
{
Rec := GlobalRec;
}
and hoped both will point to same temp table... after that i was changing only Rec variable...
if i used GetRec in the same runtime as filling rows, returned rec was still full of temp rows, but in another runing time, all rows lost
Solution is:
Function GetRec(VAR Rec Temporary)
{
Rec <- INSERTS <- GlobalRec;
}
and
Function SetRec(VAR Rec Temporary)
{
GlobalRec <- INSERTS <- Rec;
}
not as effective (copying of all rows) but working
looks like (pointer vs. *pointer problem in C syntax :roll: ) well, there are not var-var (ref-ref) variables to solve it
if all of this is crap, id like to know it, so please write here better solution or info about whats going on in referenced rec temp variablesRobert Polz0 -
Later, i tried use of RecordRef
Function GetRecRef(VAR RecRef)
{
RecRef.GETTABLE(GlobalRec);
}
It works great, no data copy, and returned RecRef had all rows inside
but, if u like to attach it to Rec variable with using of
RecRef.SETTABLE(Rec)
Rec has no rows, which is really great like many other 'qualities' of Navision =D>Robert Polz0 -
One problem that isn't mentioned here is that this solution is vulnerable to concurrency issues.
For example, if two users open up Form 1, then the values you get a race condition to determine which values actually get calculated when they open up Form 2.
With the appropriate gymnastics, one can get around this, but its probably not worth the effort, since with Luc's original approach parameters can be passed effectively.0 -
Administrator wrote:How To pass parameters between objects (forms, reports, ...)? Revisited
http://www.mibuso.com/howtoinfo.asp?FileID=9
Discuss this How To here.
I am quite new with Navision and need help for a similar situation. I am running a codeunit, from wich i run a Form. The form asks for som values and calculates some. Then when returning to the CodeUnit I need to use these values set in the form. How do I pass them back?0 -
sveivers wrote:Administrator wrote:How To pass parameters between objects (forms, reports, ...)? Revisited
http://www.mibuso.com/howtoinfo.asp?FileID=9
Discuss this How To here.
I am quite new with Navision and need help for a similar situation. I am running a codeunit, from wich i run a Form. The form asks for som values and calculates some. Then when returning to the CodeUnit I need to use these values set in the form. How do I pass them back?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
girish.joshi wrote:One problem that isn't mentioned here is that this solution is vulnerable to concurrency issues.
For example, if two users open up Form 1, then the values you get a race condition to determine which values actually get calculated when they open up Form 2.
With the appropriate gymnastics, one can get around this, but its probably not worth the effort, since with Luc's original approach parameters can be passed effectively.
each user has it's own copy. worse, if same user opens form 1 twice.
even worse is error handling. since there are no transactions on function calls, you can have wrong data stored in codeunit (for example you pass a value to single instance codeunit, then call calculation which should cleanup, but it aborts with error.. and garbage data is left in single instance codeunit).0 -
mrQQ wrote:even worse is error handling. since there are no transactions on function calls, you can have wrong data stored in codeunit (for example you pass a value to single instance codeunit, then call calculation which should cleanup, but it aborts with error.. and garbage data is left in single instance codeunit).
-Save singleinstance variables just BEFORE calling the codeunit that should use them. And in the codeunit that should use them, put them in globals or locals and remove the singleinstance variables BEFORE doing anything else.
-And if you are in object A and want to send a variable to object C but it has to pass through object B, you have to send from A to B and then from B to C.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:mrQQ wrote:even worse is error handling. since there are no transactions on function calls, you can have wrong data stored in codeunit (for example you pass a value to single instance codeunit, then call calculation which should cleanup, but it aborts with error.. and garbage data is left in single instance codeunit).
-Save singleinstance variables just BEFORE calling the codeunit that should use them. And in the codeunit that should use them, put them in globals or locals and remove the singleinstance variables BEFORE doing anything else.
-And if you are in object A and want to send a variable to object C but it has to pass through object B, you have to send from A to B and then from B to C.
which kinda beats the whole "have it easy" aspect..0 -
yeah it does defeat the purpose of having certain values stored for 'global' use if those values have to be retrieved to check their validity each time you need those values.
I think though that the how-to section is meant just to give you an idea of what is possible. If you are in a situation where it doesn't make sense to use this, then don't use it. There are still situations where it DOES make sense to use this. Just because there are a few cases where it is useless does not make the whole idea useless.0 -
I have created my own system of "more global then global variables" and I use it a lot. Of course I always keep in mind that in case of error, the variables remain dirty. That is the reason I invented the system in my previous post to avoid dirty variables. And for the moment that system works really fine. It gives me the possibility to pass parameters with little programming in stead of a lot of programming.
Of course, discipline is a must!Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
agreed:) and i didn't say it was useless, i just told about few problems0
-
In response to Robik's post and to keep all of this info about passing variables in one place:
If you are passing temporary records, as Robik describes, I don't think assignment works. I've always written my own "copy constructor" that copies all of the records from temporary record into a new temporary record variable.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