[BC Idea]: BCPT Handled event in AddLogEntry
BC Idea Link
https://experience.dynamics.com/ideas/idea/?ideaid=15563e0c-b492-ee11-a81c-000d3a7e6e50
Description
In codeunit 149005 "BCPT Line" , there is the function:
internal procedure AddLogEntry(var BCPTLine: Record "BCPT Line"; Operation: Text; ExecutionSuccess: Boolean; Message: Text; NumSQLStatements: Integer; StartTime: DateTime; EndTime: Datetime)
I would like that we put a handled integration event in the beginning of this function.
OnBeforeAddLogEntry(BCPTLine, Operation, ExecutionSuccess, Message, handled);
if Handled then
exit;
...
// Event code (wrong copy/paste in bc idea)
[IntegrationEvent(false, false)]
local procedure OnBeforeAddLogEntry(var BCPTLine: Record "BCPT Line"; var Operation: Text; var ExecutionSuccess: Boolean; var Message: Text; var Handled: Boolean)
begin
end;
Reason: Many of us run BCPT flow with random customer data to get a better representation of the data that is used. The problem with doing that is sometimes some items/customers/vendors have very special setting that makes a confirmation or message popup. In order to tackle that we do message/confirmation handlers.
But since this does not always occur we get an error for every time we didn't use the handler. An event like this can give us the possibility to skip that error if we want it.
I have seen some argument that is up to the developer to create clean test cases where the handlers are always used. To some extent that is valid. But the other side of the coin is that we have to do a lot of code cloning to make those test distinct. But the worst part is that will pollute the the actual performance test. Because now we have to filter out the records which has these particular settings. Settings that wasn't meant to be filtered upon. This will lead to that the slowest functions are those that prepares the data in the test and that makes the performance test quite useless since we can't measure the realistic flows.
@NAVFreak do I understand correctly that we need this event to supress or ignore the test failures in the log? I feel a better solution would be to have a test runner which can be setup to ignore these handler errors? Let me talk to our architects and get back to you.
Yes since some handler functions might or might not be run due to random usage of data.
One argument that it should be an event is that we can still decide which handler events that we want to bypass. In one test we want it inactivted while in another test we would like to know if there are deprecated handlers that are not used anymore. That has happened to when I have updated the customer process but don't know which handler events that was for the previous code and is now deprecated "dead code"
If you want a test not to fail on unhandled messagehandler, can't you just open a message explicitly in the test? It is not super nice but a quick fix.
I don't understand what you mean. Currently I have built my own modified version of BCPT to deal with this but since that is a bad practice/quick fix I try to move the modifications here 😉
I mean [Test] [HandlerFunctions('MessageHandler')] [Scope('OnPrem')] procedure BusinessScenario() begin ... ... ... MethodShowsMessageSometimes(); ... ... ... // Explicitly open a Message to make sure 'handler not run' error does not happen. Message('Test'); end;
Another solution would be to add capability to the BCPTTestContext to ignore message or confirm handler not being called.
Aaaah now I see. Yeah, that is an ugly workaround.
If it was only as simple as message/confirmation handlers. There could reporthandler/pagehandlers/Requestpage handlers also which makes this workaround real messy.
On Wed, Jan 10, 2024 at 10:08 PM Chethan Thopaiah @.***> wrote:
I mean [Test] [HandlerFunctions('MessageHandler')] [Scope('OnPrem')] procedure BusinessScenario() begin ... ... ... MethodShowsMessageSometimes(); ... ... ... // Explicitly open a Message to make sure 'handler not run' error does not happen. Message('Test'); end;
Another solution would be to add capability to the BCPTTestContext to ignore message or confirm handler not being called.
— Reply to this email directly, view it on GitHub https://github.com/microsoft/BCApps/issues/437#issuecomment-1885735773, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIKZT4C4EOAMONU6XFHJEEDYN37M3AVCNFSM6AAAAABAXLCOJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVG4ZTKNZXGM . You are receiving this because you were mentioned.Message ID: @.***>
Based on our discusion, it looks like raising an event gives us more flexibility other solutions we dicussed. Lets approve them:-)
@ChethanT PR is ready