Changecompany does not work
Dennis_Decoene
Member Posts: 123
Hi guys,
I'm puzzled, I made the code below to move data from an old table to a new one. When it comes to the second record, it gives this error:
It seems that for some reason a blank record is inserting. When I debug this, I see that the transferfields does the job correctly and fills the destination record.
I allso tried putting the changecompany statement before transferfields.
WTF??? ](*,) I'm using 4.0SP3 on SQL2005.
I'm puzzled, I made the code below to move data from an old table to a new one. When it comes to the second record, it gives this error:
The xxxx already exists. Identification fields an values: No.=''XXXX of course is the name of the table. "No." is indeed the primary key in that table. but in the original table there is no record with the field No. blank.
It seems that for some reason a blank record is inserting. When I debug this, I see that the transferfields does the job correctly and fills the destination record.
I allso tried putting the changecompany statement before transferfields.
IF recCompany.FINDSET THEN REPEAT
rec80001.CHANGECOMPANY(recCompany.Name);
IF rec80001.FINDSET THEN REPEAT
rec2046881.TRANSFERFIELDS(rec80001,FALSE);
rec2046881.CHANGECOMPANY(recCompany.Name);
rec2046881.INSERT;
UNTIL rec80001.NEXT=0;
rec80001.DELETEALL;
UNTIL recCompany.NEXT=0;
WTF??? ](*,) I'm using 4.0SP3 on SQL2005.
0
Answers
-
Is it possible that rec2046881 has property DataPerCompany=No?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
No...
I've changed my code, without changecompany and it gives the same error.
I'm baffled. Would there be a problem with the transferfields? I cannot imagine that, Navision uses that in their posting routines...//IF recCompany.FINDSET THEN REPEAT // rec80001.CHANGECOMPANY(recCompany.Name); IF rec80001.FINDSET THEN REPEAT rec2046881.TRANSFERFIELDS(rec80001,FALSE); //rec2046881.CHANGECOMPANY(recCompany.Name); rec2046881.INSERT; UNTIL rec80001.NEXT=0; rec80001.DELETEALL; //UNTIL recCompany.NEXT=0;0 -
When I changed the parameter of transferfields to TRUE instead of FALSE, it worked.
I wanted to keep the same timestamp and such as the original. So I set out using FALSE...0 -
I should have noticed the FALSE directly :oops:Dennis_Decoene wrote:When I changed the parameter of transferfields to TRUE instead of FALSE, it worked.
I wanted to keep the same timestamp and such as the original. So I set out using FALSE...
The timestamp is something internally for SQL for the version-principle of Navision.
The fact that you put false, didn't transfer the primary-key-fields, so you got the error.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your 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