Copy and paste record in one table

casio11
Member Posts: 13
Hi,
I want to create function or report which copy and paste record, but in same table.
Example:
I have Table1 with key KEY001(auto-increment), and i want to copy rows KEY001,KEY002... and past in the end of the Table.
I want to create function or report which copy and paste record, but in same table.
Example:
I have Table1 with key KEY001(auto-increment), and i want to copy rows KEY001,KEY002... and past in the end of the Table.
0
Best Answer
-
RockWithNAV wrote: »If the Key is Autoincrement then it will handle the Primary value itself you even dont have to worry on this.
Customer1.INIT;
Customer1.TRANSFERFIELDS(Customer2);
Customer1."No." := 0;
Customer1.INSERT;5
Answers
-
You can create a function to copy a record. You can make use of COPY or TRANSFERFIELDS functions to copy record.1
-
As @Sowkarthika has stated above you can/should use the TRANSFERFIELDS function to copy the fields from one record to another. In addition to this you must set the key field to 0 before you call the INSERT method so that the next auto-increment value can be assigned.0
-
Well TRANSFERFIELDS won't work if he works in the same table since it transfers the fields depending on field ID.
Not sure what you're trying to do.
Do you want to find first few values and then to add them at the end of your table?0 -
Well TRANSFERFIELDS won't work if he works in the same table since it transfers the fields depending on field ID.
Not sure what you're trying to do.
Do you want to find first few values and then to add them at the end of your table?
Of course TRANSFERFIELDS will work in the same table, e.g....Customer1.TRANSFERFIELDS(Customer2);
...will work perfectly well where both Customer1 and Customer2 records are for Table 18 for example.0 -
Go ahed with TRANSFERFIEDLS
Write some code like like this
Customer1.INIT;
Customer1.TRANSFERFIELDS(Customer2);
Customer1.INSERT;
Customer 2 should hold all those entries which you want to copy.
If the Key is Autoincrement then it will handle the Primary value itself you even dont have to worry on this.
Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
RockWithNAV wrote: »If the Key is Autoincrement then it will handle the Primary value itself you even dont have to worry on this.
Customer1.INIT;
Customer1.TRANSFERFIELDS(Customer2);
Customer1."No." := 0;
Customer1.INSERT;5 -
Hi Mohana,
Ya I agree that you need to write this piece of code or else you can set 0 as InitValue property but the point is I have had experienced a case where i dint need to do any of these things, seems magical but it do happened.
Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
My experience is that the AutoIncrement field does need to specifically be set to 0 prior to inserting the record as @mohana_cse06 has stated. The MSDN help also states that this should to be done ...
https://msdn.microsoft.com/en-us/library/dd338603.aspxIf you want to insert a record, be sure that the value in this field is blank before you insert the record. This is even more critical when you are using the SQL Server Option.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