Creating records during report execution
ChessExpert
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.
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.
0
Answers
-
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.0 -
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.0 -
ChessExpert wrote: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.
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
else the Navision Gods will strike down on you without mercy.
Do you make it right, it works too!0 -
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 :?:
RegardsDo you make it right, it works too!0 -
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.0 -
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.0 -
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.0
-
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 like0 -
I finally got this thing to work. Thanks everyone. I appreciate all your help. ChessExpert
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

