Using TRANSFERFIELDS

amadman114
Member Posts: 36
This is really annoying me.
I'm new to Navision, and, as you can probably tell, am still learning the basics.
I want to transfer data from one table to another. When I get this basic part working, I will refine the data.
I am trying to do this with:
The tables are exact copies of each other (I used save as and just changed the ID/Name)
However whatever I try it doesn't work as desired.
In this case it returns the error:
I've made sure there are no records in the table being written to
I'm new to Navision, and, as you can probably tell, am still learning the basics.
I want to transfer data from one table to another. When I get this basic part working, I will refine the data.
I am trying to do this with:
GrecDeletedSalesInv.GET; GrecDeletedSalesInv.TRANSFERFIELDS(SalesInvHeader, FALSE); GrecDeletedSalesInv.INSERT;
The tables are exact copies of each other (I used save as and just changed the ID/Name)
However whatever I try it doesn't work as desired.
In this case it returns the error:
The Sales Invoice Header already exists.
Identification fields and values:
No.=''
I've made sure there are no records in the table being written to
0
Comments
-
How about:
SalesInvHeader.GET; GrecDeletedSalesInv.TRANSFERFIELDS(SalesInvHeader, FALSE); GrecDeletedSalesInv.INSERT;
Did you read the help on TRANSFERFIELDS: http://msdn.microsoft.com/en-us/library/dd301438(v=nav.70).aspx?0 -
Please forget Grec, the Navision way is that programmers are supposed to understand the application logic and not blindly follow detailed specs, hence everybody knows a SalesInvHeader variable is a record type, an InvoiceAmount is a decimal type, an InvoiceCount is an integer type etc. and those who don't should not touch the code. It's a way to signal everybody if you are not familiar with the application don't try to maintain my code.
Your problem is that if you can GET the DeletedSalesInv then it has already been INSERT-ed by some other code. Or by application behavior like user on a form.
So either remove that other code that did it, or if you consider that correct behavior and in this code you need to modify an existing DeletedSalesInv, use DeletedSalesInv.MODIFY instead of INSERT.0 -
Miklos Hollender wrote:Please forget Grec, ...
..., or if you consider that correct behavior and in this code you need to modify an existing DeletedSalesInv, use DeletedSalesInv.MODIFY instead of INSERT.0 -
Thanks for the replies.
What I think I was misunderstanding (other than the GET) was that I needed to loop it for it to do it with every line in the range.
I ended up usingREPEAT CLEAR(GrecDeletedSalesInv); GrecDeletedSalesInv.TRANSFERFIELDS(GrecSalesInvHeader); GrecDeletedSalesInv.INSERT; UNTIL GrecSalesInvHeader.NEXT = 0;
0 -
As lvanvugt already told you, have a look at the help file on TRANSFERFIELDS, especially the part about the primary key fields.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
- 322 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