I am having a problem getting an error dialog to be shown. I can step right onto the line in the debugger where ERROR is called and the code unit it is called from seems to terminate, but I never see the ERROR dialog. Is this caused by other progress windows that are already being shown? Is there something I should be doing to force it to be processed?
What would Elvis do?
0
Comments
RIS Plus, LLC
If codeunit.run Then
do this or other,
you won't see the error. The code is basically capturing the error and
codeunit.run returns a true or false.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The problem can be a statement combination like this:
INSERT;
DELETE;
MODIFY; // FAILURE POINT
Message('All Done!'); // Error Point
Why? When no return value is used on database functions, the database operation set is cached and sent to the server as a batch for more efficient processing. If the debugger is not turned on, then the error will be ambiguous.
http://www.SobyLand.com
651-815-0698
anyway, here is a snippet showing how ERROR is being called:
IF EXISTS(TempReqFileName2) THEN
ERROR( 'A temporary credit card file exists.');
This line of code is being executed in a codeunit called from a codeunit called from a report, but the codeunit.run is not used. - the codeunit functions are called directly.
It seems that when ERROR is called here it is only terminating the code unit that it is called from and the message never shows up. Maybe that is just how it works?
I know that this is ‘silly’, but try to post an Error from this CU, without any IF condition (maybe on beginning of it). Try to post an error from a higher (sooner) CU, before calling CU.Function()… Move on up, until You see Error pop up. This way You will be able to specify, which CU is responsible for terminating them.
Good Luck
So, that must be what is stopping the messages. If I remove the IF statement and set a local variable with the return value from the CU.RUN statment will that allow the messages?
I guess I will try that to see. Thanks for the help
//your code
else
ERROR('Process Failed');
...be sure to see if it is the topmost lvl or you won't get the error anyway
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
That should work fine in this case - I would like to get the original message to come up but this is a good enough work-around.
RIS Plus, LLC
RIS Plus, LLC
Basically:
If you use the return value of the codeunit it suppresses the error, otherwise you should see the actual message come up.
RIS Plus, LLC
with IF CONFIRM('error triggered , do you want to terminate transaction ?') THEN ERROR(...)