copy a VAR parameter of a function to a global var

boubounas
Member Posts: 17
Hi there,
I have the following code:
My parameter has MyRec.COUNT equal to 3. After I copy it to MyGlobalRec with either of the above ways then MyGlobalRec.COUNT is equal to 1. Can someone explaing why please? And how can I copy all 3 records to my global variable?
Note that I get the same results if I try to copy MyRec into Rec.
Thanks in advance.
I have the following code:
SetMyRecord(VAR MyRec : Record) MyGlobalRec.COPY(MyRec); //or even MyGlobalRec := MyRec;
My parameter has MyRec.COUNT equal to 3. After I copy it to MyGlobalRec with either of the above ways then MyGlobalRec.COUNT is equal to 1. Can someone explaing why please? And how can I copy all 3 records to my global variable?
Note that I get the same results if I try to copy MyRec into Rec.
Thanks in advance.
"After 5 billion years man said: Let there be God"
0
Answers
-
I haven't tried it yet but try to loop through MyRec and
insert them into MyGlobalRec.0 -
MyGlobalRec := MyRec;
this code fills the fields in the MyGlobalRec with the values in the MyRec. this code does not change the record count of MyGlobalRec. COUNT is calculated according to filters.MyGlobalRec.COPY(MyRec);
this must work.after this line, MyGlobalRec must have 3 records.. can you post the all of your code please? i want to see how you filtered the record,when you called SetMyRecord function, etc..SetMyRecord(VAR MyRec : Record) MESSAGE(FORMAT(MyRec.COUNT)); MESSAGE(FORMAT(MyGlobaRec.COUNT)); MyGlobalRec.COPY(MyRec); MESSAGE(FORMAT(MyGlobaRec.COUNT));
also, can you check the messages in the shown above?0 -
Your MyRec record set probably includes MARKED records which are not copied neither by COPY nor by COPYFILTERS.
One way to solve the problem is cycling through all (MARKED) records and create a filter string based on primary key...
e.g.MyGlobalRec.RESET; MyRec.FIND('-'); REPEAT IF STRLEN(strTableFilter) > 0 THEN strTableFilter := strTableFilter + '|' ; strTableFilter := strTableFilter + FORMAT(MyRec.RecordID); UNTIL MyRec.NEXT() = 0; MyGlobalRec.SETFILTER(RecordID, strTableFilter);
Hope this helps...0 -
ayhan06 wrote:i want to see how you filtered the record,when you called SetMyRecord function, etc..
also, can you check the messages in the shown above?
Ayhan, thanks for your reply.
MyRec does NOT have any filters at all. And just to make sure, I do a MyRec.RESET just before I call the SetMyRecord function.
Here is what you asked:SetMyRecord(VAR MyRec : Record) MESSAGE(FORMAT(MyRec.COUNT)); // Message here is: 3 MESSAGE(FORMAT(MyGlobaRec.COUNT));// Message here is: 0 MyGlobalRec.COPY(MyRec); MESSAGE(FORMAT(MyGlobaRec.COUNT));// Message here is: 1
"After 5 billion years man said: Let there be God"0 -
Krokce wrote:Your MyRec record set probably includes MARKED records which are not copied neither by COPY nor by COPYFILTERS.
Hi Krokce, thanks for your reply.
I did a MyRec.MARKED just before I call the SetMyRecord function and returned FALSE which means that it doesnt contain any marked records.
Can someone try it plz, its quick."After 5 billion years man said: Let there be God"0 -
I found the problem and the solution. The problem was that MyGlobalRec and MyRec (the parameter to the function) were temporary, meaning that the table is temporary and so it doesnt have any entries. So when MyGlobalRec even after the copy function is points to an empty table.
The solution is looping through and inserting the entries from MyRec to MyGlobalRec:SetMyRecord(VAR MyRec : Record Item) IF MyRec.FIND('-') THEN REPEAT MyglobalRec := MyRec; // not necessary to copy with filters for the insert MyglobalRec.INSERT; UNTIL MyRec.NEXT = 0; ...
"After 5 billion years man said: Let there be God"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