mibuso.com

Microsoft Business Solutions online community
It is currently Fri Mar 27, 2015 6:18 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: How To pass parameters between objects (forms..) Revisited
PostPosted: Tue Jul 05, 2005 1:42 pm 
Offline
Site Admin

Joined: Sun Nov 07, 1999 7:01 am
Posts: 2136
Location: Wilrijk, Belgium
Country: Belgium (be)
How To pass parameters between objects (forms, reports, ...)? Revisited

http://www.mibuso.com/howtoinfo.asp?FileID=9

Discuss this How To here.


Top
 Profile  
 
 Post subject: Great How To!
PostPosted: Tue Jul 05, 2005 2:06 pm 
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.


Top
  
 
 Post subject: Temporary records
PostPosted: Wed Aug 24, 2005 10:37 pm 
Offline

Joined: Sat Oct 09, 2004 5:04 pm
Posts: 7
Location: Prague
Country: Czech Republic (cz)
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 what

_________________
Robert Polz


Top
 Profile E-mail  
 
 Post subject: Re: Temporary records
PostPosted: Wed Aug 24, 2005 11:33 pm 
Offline

Joined: Sat Oct 09, 2004 5:04 pm
Posts: 7
Location: Prague
Country: Czech Republic (cz)
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 what


:) i 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 variables

_________________
Robert Polz


Top
 Profile E-mail  
 
 Post subject: Another research :)
PostPosted: Thu Aug 25, 2005 8:54 pm 
Offline

Joined: Sat Oct 09, 2004 5:04 pm
Posts: 7
Location: Prague
Country: Czech Republic (cz)
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 Polz


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 8:27 pm 
Offline

Joined: Wed Sep 07, 2005 4:06 pm
Posts: 380
Location: Washington D.C.
Country: United States (us)
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.


Top
 Profile  
 
 Post subject: Re: How To pass parameters between objects (forms..) Revisit
PostPosted: Wed Jan 03, 2007 3:17 pm 
Offline

Joined: Wed Jan 03, 2007 3:03 pm
Posts: 2
Location: Norway
Country: Norway (no)
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?


Top
 Profile  
 
 Post subject: Re: How To pass parameters between objects (forms..) Revisit
PostPosted: Thu Jan 04, 2007 5:56 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7723
Location: Milan
Country: Italy (it)
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?

You can also use this system. But the saving of parameters must be done in the form and the retrieving in the codeunit.

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 1:01 pm 
Offline

Joined: Mon Nov 29, 2004 9:42 am
Posts: 236
Location: Kaunas
Country: Lithuania (lt)
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).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 1:09 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7723
Location: Milan
Country: Italy (it)
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).

How to avoid this:
-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
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 1:49 pm 
Offline

Joined: Mon Nov 29, 2004 9:42 am
Posts: 236
Location: Kaunas
Country: Lithuania (lt)
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).

How to avoid this:
-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..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 2:00 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Thu Jan 02, 2003 5:37 pm
Posts: 7995
Location: Flagstaff, AZ
Country: United States (us)
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.

_________________
Daniel Rimmelzwaan
KCP Dynamics
MVP - Dynamics NAV


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 2:07 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Wed Jul 02, 2003 9:13 am
Posts: 7723
Location: Milan
Country: Italy (it)
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
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website: http://www.navtechdays.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 2:34 pm 
Offline

Joined: Mon Nov 29, 2004 9:42 am
Posts: 236
Location: Kaunas
Country: Lithuania (lt)
agreed:) and i didn't say it was useless, i just told about few problems :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 4:20 pm 
Offline

Joined: Wed Sep 07, 2005 4:06 pm
Posts: 380
Location: Washington D.C.
Country: United States (us)
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: