Why inserting from a report do not work?

Imaspal
Member Posts: 68
Hi Experts!
I'm trying to insert a record to the table from a report, but this doesn't work. My table is empty after I'm using the INSERT-function in my report's OnPreReport - Trigger.
Can you help me with this, what is wrong?
Yours,
Imaspal
I'm trying to insert a record to the table from a report, but this doesn't work. My table is empty after I'm using the INSERT-function in my report's OnPreReport - Trigger.
Can you help me with this, what is wrong?
Yours,
Imaspal
0
Comments
-
Can you give the complete code you wrote?
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
popps up an error:?:
your Table variable is not temporary :?: You make YourtableVariable.insert() :?: Lets see the source
RegardsDo you make it right, it works too!0 -
There is no error, after running following code the table tmpSalesPersonPurchaser is empty.
I'm not using a temporary table-variable, is this the problem?
My sourcecode looks like this:tmpSalesPersonPurchaser.INIT; SalespersonPurchaser.RESET; IF SalespersonPurchaser.FINDSET THEN REPEAT tmpSalesPersonPurchaser.Code := SalespersonPurchaser.Code; tmpSalesPersonPurchaser.Name := SalespersonPurchaser.Name; tmpSalesPersonPurchaser.Code2 := SalespersonPurchaser.Code; tmpSalesPersonPurchaser.INSERT; UNTIL SalespersonPurchaser.NEXT = 0; tmpSalesPersonPurchaser.Code := FORMAT(CURRENTDATETIME,0,'<Day,2><Hours24><Minutes,2>'); tmpSalesPersonPurchaser.Name := Text002; tmpSalesPersonPurchaser.Code2 := ''; tmpSalesPersonPurchaser.INSERT;
0 -
tmpSalesPersonPurchaser and SalespersonPurchaser on the same table (13) :?: tmpSalesPersonPurchaser is temporary or (Proper< of variable)Do you make it right, it works too!0
-
Maybe you should be in the OnAfterGetRecord, not the OnPreReport (this trigger happens before any of the sections are read). Or maybe you are intentionally purring it there, but without the code to see we cannot know...
-a0 -
it must work. the code is correct. The OnPreReport Trigger can also be used.
Do you have checked if SalesPersons are exist or do you have started the debugger to see what navision is doing :?:
regardsDo you make it right, it works too!0 -
garak wrote:it must work. the code is correct. The OnPreReport Trigger can also be used.
Do you have checked if SalesPersons are exist or do you have started the debugger to see what navision is doing :?:
There are Salespersons on table 13.
I tried to run this same code with codeunit and it worked. When I tried to run this codeunit from my report's OnPreReport trigger => this did not work. The table was empty the same way as it was, when tried to run this code straight from my report.
I haven't tried the debugger yet..I let you know, if I find the problem with debugger.
Yours,
IP0 -
you have
"tmpSalesPersonPurchaser" variable
I suppose that tmp prefix means that this variable is temporary...
you won't find records inserted if you insert them in a temporary variable...
did you check if the variable is temporary (as garak suggest)?
8)0 -
Belias wrote:you have
"tmpSalesPersonPurchaser" variable
I suppose that tmp prefix means that this variable is temporary...
you won't find records inserted if you insert them in a temporary variable...
did you check if the variable is temporary (as garak suggest)?
8)
Yes I checked it. The variable is not temporary.
Yours,
IP0 -
You should run the debugger and see if it hits your code at all.
Otherwise try the below. Using CONFIRM as opposed to message pauses the code so you know exactly where youa re...
if not confirm(format(tmpSalesPersonPurchaser.count)) then
error('');
tmpSalesPersonPurchaser.INIT;
SalespersonPurchaser.RESET;
IF SalespersonPurchaser.FINDSET THEN
REPEAT
tmpSalesPersonPurchaser.Code := SalespersonPurchaser.Code;
tmpSalesPersonPurchaser.Name := SalespersonPurchaser.Name;
tmpSalesPersonPurchaser.Code2 := SalespersonPurchaser.Code;
tmpSalesPersonPurchaser.INSERT;
UNTIL SalespersonPurchaser.NEXT = 0;
if not confirm(format(tmpSalesPersonPurchaser.count)) then
error('');
tmpSalesPersonPurchaser.Code := FORMAT(CURRENTDATETIME,0,'<Day,2><Hours24><Minutes,2>');
tmpSalesPersonPurchaser.Name := Text002;
tmpSalesPersonPurchaser.Code2 := '';
tmpSalesPersonPurchaser.INSERT;
if not confirm(format(tmpSalesPersonPurchaser.count)) then
error('');0 -
Belias wrote:sorry, maybe I didn't explain well.
i mean: have you got "tmpSalesPersonPurchaser" in globals and another "tmpSalesPersonPurchaser" in the locals(of the trigger/function where your code is)?
No, there is only a global variable "tmpSalesPersonPurchaser"´in trigger OnPreReport
Yours,
IP0 -
so, whats the result from debugging?Do you make it right, it works too!0
-
The debugger seems to hit my code.
Yours,
IP0 -
Is there an error later in the report? If there is an error then the insertions will be rolled back.
What is the table number of both the variables:
SalespersonPurchaser
tmpSalesPersonPurchaser
I would like to see the results of putting in the COUNTS in the code to see if anything is inserted.0 -
If I had to guess it is because you have INIT and then RESET proceeding after it. (Yes I am aware the two calls are being made to two separate variables. But they are the same table no?)0
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