Hello experts
I have a strange bevavior in a testing scenario.
There is a table called table1, the modify trigger looks like this
Error('test error');
There is a codeunit with this code
table1.find('-');
table1.code := table1.code + 'x';
if not table1.modify(true) then
message('my error handling');
If the codeunit is run, guess what message appears. It's not 'my error handling', it's 'test error'.
Whats the reason for this? I thought if the return value of the modify trigger is handled by the code, the error in the respective trigger does not fire ](*,)
Thanks in advance
Thomas
Comments
when you use table1.MODIFY(TRUE) it fires the OnModify trigger of the table1.
If you need to get your error message use table1.MODIFY THEN
Albert
Thanks, I know that I could do that. But I need to use the table trigger, because in my real life scenario there are some very complicated checks on this trigger which I cannot duplicate.
Any other ideas?
Maybe you could remove the error messages in the OnModify trigger
but then when the table is updated from a form then you would probably
need these error messages.
Maybe for your scenario you could use something like the SetHideValidationDialogue of the sales header table.
Albert
I will check what I can do.
But I'm still quite wondering why the error is firing when I use the return value of the trigger function. :?
Even though you are using the return value it still runs all the
code in the OnModify trigger and if you have an ERROR statement this will be executed.
Albert
imho in mycodeunit there can be ANY error and they never fire if the return value is used. So I wonder why this does not work here. Additionally I think I have seen constructs like
The "if codeunit.run" option is only available for codeunits.
Ok get your point. What you will have to do is create another codeunit to call your modifying codeunit.
i.e MyCU1
MyCU2
Albert
I think you're right. But then what is the return value for table triggers used for?
Someone other has some thoughts on this? Thanks in advance
Thomas