Initializing a global variable in the Insert trigger of a table loses its content in onvalidate field.
Runnig the same triggers within a codeunit it works fine, the variable shows the expected value.
That's what I've done:
Create a table with two fields
"No" as code10 and primary key
"Customer No" as code 20 and related to the customer table
Declare a global variable gAlert as Text 20
In the insert event of the table initialize the global variable: gAlert := 'Test';
In the "Customer No" validate function insert a message: MESSAGE ('Value of: ' + gAlert);
Create a page related to that table with both fields
Run the page and create new record. In the “Customer no” Validate event, the pop up window I've got says: "Value of:".
gAlert has the value '' in the "Customer No" validate event
Create a Code unit with this code:
a Global variable rTest as a record that points the previous table
rTest.INIT;
rTest."No" := '001';
rTest.INSERT(TRUE);
rTest.VALIDATE("Customer No", '10000');
rTest.MODIFY(TRUE);
And when running the Code unit, I've got the message "Value of: Test";
Can anybody explain why this distinct behavior?
It has been tested in NAV 2009R2, 2013 and 2016
Runnig the same triggers within a codeunit it works fine, the variable shows the expected value.
That's what I've done:
Create a table with two fields
"No" as code10 and primary key
"Customer No" as code 20 and related to the customer table
Declare a global variable gAlert as Text 20
In the insert event of the table initialize the global variable: gAlert := 'Test';
In the "Customer No" validate function insert a message: MESSAGE ('Value of: ' + gAlert);
Create a page related to that table with both fields
Run the page and create new record. In the “Customer no” Validate event, the pop up window I've got says: "Value of:".
gAlert has the value '' in the "Customer No" validate event
Create a Code unit with this code:
a Global variable rTest as a record that points the previous table
rTest.INIT;
rTest."No" := '001';
rTest.INSERT(TRUE);
rTest.VALIDATE("Customer No", '10000');
rTest.MODIFY(TRUE);
And when running the Code unit, I've got the message "Value of: Test";
Can anybody explain why this distinct behavior?
It has been tested in NAV 2009R2, 2013 and 2016