Creating records during report execution

ChessExpertChessExpert Member Posts: 103
Hello there experts.

I am trying to "INSERT" table row entries while running the report.

I have something like this on the ONAFTERGETRECORD


Count := Count + 1;
TempGLEntry.INIT;
TempGLEntry."No." := FORMAT(Count,5);
TempGLEntry.INSERT;

My problem is that, it wasn't writing the data to the table.

I have tried to use other tables and temporary table too but had no success.

Is it possilble on "REPORT" objects to "INSERT" or create records to other table while it is running?

I just wanted to store some field content from that report, e.g. "GL Account No." that I can use it later for processing and comparison.

Thank you in advance for your advice.

Answers

  • matttraxmatttrax Member Posts: 2,309
    There should be no problem inserting/modifying/deleting data from a report.

    Make sure the code in the OnAfterGetRecord trigger is actually executing. (What is your data item and what are the filters on it?)

    Since you're not setting "Entry No." which is the primary key for "G/L Entry" and you're not catching the INSERT with a conditional my guess is it is not executing at all. Otherwise you'd get an error that says the entry already exists.
  • DenSterDenSter Member Posts: 8,305
    If your TempGLEntry variable is a temporary record variable, it is not going to insert into the database because it's a temporary variable, they aren't supposed to insert anything into the database.

    Why are you inserting GL Entries anyway? You should not be doing that. Create general journal lines and post those and let NAV take care of processing those into GL entries.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Hello there experts.

    I am trying to "INSERT" table row entries while running the report.

    I have something like this on the ONAFTERGETRECORD


    Count := Count + 1;
    TempGLEntry.INIT;
    TempGLEntry."No." := FORMAT(Count,5);
    TempGLEntry.INSERT;

    My problem is that, it wasn't writing the data to the table.

    I have tried to use other tables and temporary table too but had no success.

    Is it possilble on "REPORT" objects to "INSERT" or create records to other table while it is running?

    I just wanted to store some field content from that report, e.g. "GL Account No." that I can use it later for processing and comparison.

    Thank you in advance for your advice.

    1. Check the Property of the TempGLEntry record variable and ensure the Temporary is set to No.
    2. Run your report through the debugger and ensure the report is looping properly.
    3. Make sure you know what you're doing by inserting directly into the G/L Entry table or else the Navision Gods will strike down on you without mercy. :wink:
  • garakgarak Member Posts: 3,263
    else the Navision Gods will strike down on you without mercy.
    :D
    Do you make it right, it works too!
  • garakgarak Member Posts: 3,263
    1. a temporary table doesn't store the datas in the database only in your cache
    2. in a report you can insert / modify / delete datas in real tables also in temp. tables
    3. use debugger to see what your report do
    4. Do you really want to insert G/L Entries in the database or only temp. for example for a special sort :?:

    Regards
    Do you make it right, it works too!
  • ChessExpertChessExpert Member Posts: 103
    edited 2008-07-22
    Thank you all for your reply.

    I actually have an existing report based on GLEntry table. It works fine. But I have another report requirement that is the same "Detailed Report" but the Total Per GL Account Summary should be greater than 100K.

    So I was planning to create two DATAITEMS.

    a. The first one would be non-printing, and should be able to create GL Code and accumulate the amount. (THIS IS THE PART WHERE I WOULD LIKE TO CREATE A RECORD)

    PROBLEM: I have to use a temporary table to store the content.

    b. The second dataitem which is the same GL Entry table, but I have to check the existence of it in the temporary "TABLE GENERATED FROM FIRST LOOP", if it is greater than 100K.

    Is this a good idea or is there a better way to do it. I am new to accessing or creating temporary table. Thanks a lot.
  • DenSterDenSter Member Posts: 8,305
    You don't need to have two dataitems for that. This can be easily accomplished by grouping your G/L Entry dataitem by G/L Account number, and putting totals in a groupfooter.

    You should get some training on NAV development, you would be amazed at how simple these things can be.
  • ChessExpertChessExpert Member Posts: 103
    Thanks for your prompt reply Denster. I have edited my previous posting. Anyway, my requirement is actually the same "Detailed Report" but it should show only the entries where total per "GL Account" is greater than 100K.
  • DenSterDenSter Member Posts: 8,305
    I'd probably insert a dataitem for G/L Account as the root dataitem, indent the G/L Entry dataitem with a link to the G/L Account number (plus any additional filters you need), and in OnAfterGetRecord of the Account:
    "G/L Account".CALCFIELD(Balance);
    IF "G/L Account".Balance < 100000 THEN
      CurrReport.SKIP;
    
    This is just an idea, haven't seen your report, don't know what it looks like
  • ChessExpertChessExpert Member Posts: 103
    I finally got this thing to work. Thanks everyone. I appreciate all your help. ChessExpert :D
Sign In or Register to comment.