How to insert records of "No" field of "GL account" table into my new table's "New Table" field.

Deepak_Jamwal
Member Posts: 13
I just want to know that where I have to write this code.
Can I write this code in my new table's trigger.
Can I write this code in my new table's trigger.
0
Answers
-
Hi @Deepak_Jamwal ,
Quite unclear question. Do you want to copy data from G/L Account to your new table? Or what?Let's go!0 -
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?1
-
hi @logger,
yes I want to copy all records of only "No." field of G/L account table into my new table.0 -
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.Let's go!0 -
0
-
@logger
rather then creating a report is there any other option where I can write the code for this task.
0 -
@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.
Let's go!0 -
Report is best solution because report do repeat-until loop itself. You need only:
NewTable.INIT;
NewTable."No." := "No.";
NewTable.Insert;1
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