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.
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...
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 :?:
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.
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)
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso My Blog
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)
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)?
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso My Blog
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('');
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
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?)
Comments
Tino Ruijs
Microsoft Dynamics NAV specialist
your Table variable is not temporary :?: You make YourtableVariable.insert() :?: Lets see the source
Regards
I'm not using a temporary table-variable, is this the problem?
My sourcecode looks like this:
-a
In this case tmpSalesPersonPurchaser and SalespersonPurchaser are different tables.
Yours,
Imaspal
Do you have checked if SalesPersons are exist or do you have started the debugger to see what navision is doing :?:
regards
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,
IP
"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)
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Yes I checked it. The variable is not temporary.
Yours,
IP
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Both variables are Globals.
Yours,
IP
i mean: have you got "tmpSalesPersonPurchaser" in globals and another "tmpSalesPersonPurchaser" in the locals(of the trigger/function where your code is)?
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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('');
No, there is only a global variable "tmpSalesPersonPurchaser"´in trigger OnPreReport
Yours,
IP
Yours,
IP
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.