Strange behavior of temp record
ta5
Member Posts: 1,164
Hello
I have a problem working with temporary records. The problem occurs as soon as I'm working on a copy of a temporary record. Of course this is just an example.
Please note, the 2nd loop does not work, as Currency2.find('-') is false.
Any ideas? I think, I'm missing something ](*,)
Thanks a lot
Thomas
I have a problem working with temporary records. The problem occurs as soon as I'm working on a copy of a temporary record. Of course this is just an example.
// create to records in temporary table
FOR iTemp := 1 TO 2 DO BEGIN
Currency.Code := 'Code ' + FORMAT(iTemp);
Currency.INSERT;
END;
// loop trough temporary records
IF Currency.FIND('-') THEN BEGIN
REPEAT
MESSAGE('loop on original temp record: %1',Currency.Code);
UNTIL Currency.NEXT = 0;
END;
// make a copy of the temporary record, Currency2 is temporary too
Currency2 := Currency;
// loop through copy of temporary record
// DOES NOT WORK!
IF Currency2.FIND('-') THEN BEGIN
REPEAT
MESSAGE('loop on copy of temp record: %1',Currency2.Code);
UNTIL Currency2.NEXT = 0;
END;
Please note, the 2nd loop does not work, as Currency2.find('-') is false.
Any ideas? I think, I'm missing something ](*,)
Thanks a lot
Thomas
0
Answers
-
// make a copy of the temporary record, Currency2 is temporary too
Currency2 := Currency;
This will not copy your records into Currency2.
You'll need an INSERT...0 -
Thanks, but imho it works when currency and currency2 are not temporary. For testing this I also dont use the 2 inserts at the beginning of the codeunit.
What do you think?0 -
Think of := as a reference to a record.
The find('-') works in Normal tables because the entries exist. When working with temporary tables they don't exist. you need a loop to copy all the records from one variable to the other...0 -
Ok thanks.
The problem is the following. My code example was just for demonstration purposes. I actually try to pass a record variable to another object (form or report). This is a bit difficult to show in an example, but same problem there. Working with non-temporary vars works just fine, working with temporary vars don't.
Any ideas appreciated
Thomas0 -
from a quick test I think what you want to achieve can be done using the command
Rec.COPY(FromRecord[,ShareTable]) which is available (with the extra parameter) only in version 6...
In prior versions you will need to pass the parameter as a VAR and then loop through the records and add them in your Temporary Global Variable...0 -
A temporary record variable is just empty memory that is structured like the table you base the variable on. Every time you use a new temp variable, it starts out empty. You have to fill the temp table with the temporary records. Because currency and currency2 are two different variables, they point to different sections of the memory. They are two dofferent entities.ta5 wrote:Thanks, but imho it works when currency and currency2 are not temporary.
If it's not a temp record it points to the actual table. You will see all records for every non-temporary record variable, because they all point to the same table, you are looking at actual physical records in the physical table. The two variables are two different objects in memory, but they point at the same thing.
If you want to fill a temp record in one object and send the whole thing into another, you'll have to pass it by reference (i.e. with the VAR checkbox ticked in the parameter screen). Also make sure that the parameter itself is temporary.0 -
kapamarou wrote:In prior versions you will need to pass the parameter as a VAR and then loop through the records and add them in your Temporary Global Variable...
Thanks, this works, the code now loops through the parameter in the remote function (passed by reference). Then another temporary variable of the same type is filled with the values. Maybe not the sleekest way, but with only a few records we need it for its ok.
Thanks also to Daniel for his explanations!
Thomas0 -
Always happy to help
good to hear that you were able to make it work. 0 -
And once more:
Mibuso.com is THE place to get infos like that!!0 -
Happy we could help...0
-
[The use of [SOLVED] in the Topic Title is no longer supported. Please edit the first message in the thread and use the field Attribute (below the Subject-field) to put a green checkmark next to the Topic Title]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

