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

I just want to know that where I have to write this code.
Can I write this code in my new table's trigger.

Answers

  • loggerlogger Member Posts: 126
    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!
  • latronamarranlatronamarran Member Posts: 24
    edited 2017-11-22
    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?
  • Deepak_JamwalDeepak_Jamwal Member Posts: 13
    hi @logger,
    yes I want to copy all records of only "No." field of G/L account table into my new table.
  • loggerlogger Member Posts: 126
    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!
  • Deepak_JamwalDeepak_Jamwal Member Posts: 13
    hello @latronamarran,
    I am using MS NAV 2016
    Version 9.00.47864
  • Deepak_JamwalDeepak_Jamwal Member Posts: 13
    @logger
    rather then creating a report is there any other option where I can write the code for this task.
  • loggerlogger Member Posts: 126
    @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!
  • lubostlubost Member Posts: 627
    Report is best solution because report do repeat-until loop itself. You need only:
    NewTable.INIT;
    NewTable."No." := "No.";
    NewTable.Insert;
Sign In or Register to comment.