if you would like the create records for existing GL Account records, then you need to write a simple repeat-until, init-insert statement and run it for once. if you want to create a new table record when a new gl account is inserted then you need to write the code to the oninsert trigger of the GL Account table. which version of NAV are you working with?
To copy ALL existing data, you should use repeat-until and so on as @latronamarran already mentioned. Just create ProcessingOnly report and use G/L Account as dataitem.
To catch new inserting in G/L Account:
1/ If you use NAV 2016 and later versions, you can use Event Subscriptions to make your new table catch inserting in G/L Account.
2/ If 2015 or earlier, you should create new function in G/L Account table to copy newly added account to your new table. Don't forget to call this new function in OnInsert trigger of G/L Account table.
@Deepak_Jamwal ,
If you mean copiing data you have various options. E.g.:
1/ create codeunit and write transferring operation code in OnRun trigger;
2/ create T-SQL script and run it on your MS SQL Server.
Answers
Quite unclear question. Do you want to copy data from G/L Account to your new table? Or what?
yes I want to copy all records of only "No." field of G/L account table into my new table.
To catch new inserting in G/L Account:
1/ If you use NAV 2016 and later versions, you can use Event Subscriptions to make your new table catch inserting in G/L Account.
2/ If 2015 or earlier, you should create new function in G/L Account table to copy newly added account to your new table. Don't forget to call this new function in OnInsert trigger of G/L Account table.
I am using MS NAV 2016
Version 9.00.47864
rather then creating a report is there any other option where I can write the code for this task.
If you mean copiing data you have various options. E.g.:
1/ create codeunit and write transferring operation code in OnRun trigger;
2/ create T-SQL script and run it on your MS SQL Server.
NewTable.INIT;
NewTable."No." := "No.";
NewTable.Insert;