I am using Navision Attain US 3.01.A Beta 2. It looks like Navision looses the reference in some cases, when calling functions from Codeunits. For example, I have code like this : FILTERGROUP(2); recordname.SETRANGE(“Shortcut Dimension 1 Code”, somevalue); FILTERGROUP(0); If I put this code in the OnActivate Form Trigger, it does filter the form. But if I have similar code in a function of a codeunit and call the function from the same trigger, transmitting Rec as parameter it does not filter the form in some cases. One example is the form 132 “Posted Sales Invoice”. For most of the forms calling the function from the codeunit works just fine. I could not figure it out, what is special about the forms that don’t work, I’m wonderring if anybody else has run into the same problem. Thanks, Carmen
Hi Carmen, do i get it right ? From a form you call a function which is defined in a codeunit. To that function you hand over a record-variable as a parameter and then you perform some filtering on this record-variable inside that function. In the function, where you define the parameters - is there the VAR-field checked ? That way you perform a “call-by-reference”, otherwise a “call-by-value”. Take look at that. Richard
quote:
Originally posted by rmotzer: Hi Carmen, do i get it right ? From a form you call a function which is defined in a codeunit. To that function you hand over a record-variable as a parameter and then you perform some filtering on this record-variable inside that function. In the function, where you define the parameters - is there the VAR-field checked ? That way you perform a “call-by-reference”, otherwise a “call-by-value”. Take look at that. Richard
Reports and Forms only receive a copy of the filters that have been applied. Codeunits on the other hand either receive a copy of the record (exact copy with all values but, no filters) or the actual record stored in memory (that is passed by memmory address…think pointers in C++). If you want to retain a copy of the filters you must pass the variable by reference (Var checked). Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117
OOOps!!! This is one of those emberassing situations where you looked at a problem so much that you don’t see the obvious anymore. You are correct. Somehow the Var checkbox got unchecked, and I always assumed it was checked and never verified. Another lesson to learn. Thank you, Carmen