Error: RecordReference and Changecompany

Clemens_Liedke
Member Posts: 4
Hello,
I want to read out data from various tables from different companys by RecordRefs and RecordIDs,
For example: for company "A" I want to read Item 1000, for company "B" I want to read item 1001. So I wrote :? the RecordIDs of item 1000 and 1001 in a new table with "Data Per Company" = No
In a new Codeunit I am reading every Company in a loop. When I am logged on in company "A", I get an error by a RecRef.GET of company "B". What's wrong with my sourcecode? I am using Version 4 SP1 with Build 21666 with Native Database.
Table OutputRecords with "Data Per Company" = No
Primary Key: Field 1+2
1 Companyname Text 30
2 Transaction No. BigInteger
3 RecordID RecordID
4 Table No Integer
Sourcecode:
Company.RESET;
IF Company.FIND('-') THEN
REPEAT
OutputRecords.RESET;
OutputRecords.SETCURRENTKEY(Companyname,"Table No");
OutputRecords.SETRANGE(Companyname,Company.Name);
IF OutputRecords.FIND('-') THEN
REPEAT
RecRef.OPEN(OutputRecords."Table No",FALSE,Company.Name);
RecRef.GET(OutputRecords.RecordID); <----CAUSE AN ERROR for foreign Companies
UNTIL OutputRecords.NEXT = 0;
UNTIL Company.NEXT = 0;
I want to read out data from various tables from different companys by RecordRefs and RecordIDs,
For example: for company "A" I want to read Item 1000, for company "B" I want to read item 1001. So I wrote :? the RecordIDs of item 1000 and 1001 in a new table with "Data Per Company" = No
In a new Codeunit I am reading every Company in a loop. When I am logged on in company "A", I get an error by a RecRef.GET of company "B". What's wrong with my sourcecode? I am using Version 4 SP1 with Build 21666 with Native Database.
Table OutputRecords with "Data Per Company" = No
Primary Key: Field 1+2
1 Companyname Text 30
2 Transaction No. BigInteger
3 RecordID RecordID
4 Table No Integer
Sourcecode:
Company.RESET;
IF Company.FIND('-') THEN
REPEAT
OutputRecords.RESET;
OutputRecords.SETCURRENTKEY(Companyname,"Table No");
OutputRecords.SETRANGE(Companyname,Company.Name);
IF OutputRecords.FIND('-') THEN
REPEAT
RecRef.OPEN(OutputRecords."Table No",FALSE,Company.Name);
RecRef.GET(OutputRecords.RecordID); <----CAUSE AN ERROR for foreign Companies
UNTIL OutputRecords.NEXT = 0;
UNTIL Company.NEXT = 0;
0
Comments
-
Try something like this:
Company.RESET; IF Company.FIND('-') THEN REPEAT OutputRecords.RESET; OutputRecords.SETCURRENTKEY(Companyname,"Table No"); OutputRecords.SETRANGE(Companyname,Company.Name); IF OutputRecords.FIND('-') THEN REPEAT RecRef.OPEN(OutputRecords."Table No",FALSE,Company.Name); // now it depends on what you have in "OutputRecords.RecordID". // So you have to use one of these:(RECORDID,SETPOSITION OR fill up the keyfields 1 by 1) RecRef.RECORDID(OutputRecords.RecordID); RecRef.SETPOSITION(OutputRecords.RecordID); RecRef.FIND('='); // get the record by using the values in the primary-key fields. UNTIL OutputRecords.NEXT = 0; UNTIL Company.NEXT = 0;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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