Sometimes there is a need to copy the data that is in one table into a new table. This can be due to synchronization issues where the data in a table may be lost, just wanting to tinker with the data, or whatever other reason you want. Here is a basic way to do this.
- In the development workspace, right click on the table (we will call this daxTable) and select 'Duplicate'. This will create a new table. We will rename this table daxTable_Copy
- Copy, paste, and run the below code into an AX job
Note that the recId and recVersion will not come over in this call. If other tables rely on this table's recId, this will screw some stuff up moving the data around.
// Copy data from one dropped table to another
static void daxCopyTableData(Args _args)
{
DAXTable daxTable;
DAXTable_Copy daxTable_Copy;
;
ttsBegin;
// Clear the data from the copy table
delete_from daxTable_Copy;
while select daxTable
{
buf2Buf(daxTable, daxTable_Copy);
daxTable_Copy.insert();
}
ttsCommit;
}
thank u for your coding
ReplyDeleteYou're very welcome! Thanks for visiting and leaving a comment that indicates it was helpful! I really do appreciate the feedback and knowing that these posts help people. It's why I do it :-)
Deletebut how to copy the content of the particular field
ReplyDeleteYou would do a general assignment of field to field from the two tables. such as 'daxTable_Copy.Field1 = daxTable.Field1'. After the copy, you can manipulate whatever fields you want. This example was strictly for a 1:1 identical copy process.
DeleteThank u
DeleteHi Justin,
ReplyDeleteDoubt on From!
How to copy the selected record from one form to another form.
Thanks In Advance!!!
Same Question from My Side Too...??
DeleteHow to copy a single record from one form to another form? You would want to select the record (or multiple) on the source grid. Then I would write the data selected to the table that is being displayed on the other form. Assuming the form is open, you should just be able to refresh the destination form grid and the data will show up. May not be as cut and dry in your scenario but it should work.
DeleteThe grids in forms are basically just there to display data that exists in the backend. So you'll need to write the data in the backend so the data will show up in the front end.
Did that help? Did I miss the question?
Getting this Error while runing the job--> " Error executing code: The field with ID '60009' does not exist in table 'daxTable_Copy' "
ReplyDeleteEven I am getting the same error while running the job.Did u findout any solution for this problem.
DeleteJust verify your field Id in the properties of a certain field in both original and duplicate table.if all the field Id's are equal.it will copy the data,if not recreate the table and try it.
DeleteThis comment has been removed by the author.
ReplyDeletedsd
ReplyDeleteSorry ! I just test the comment section.
Delete