PROCEDURE ExecuteResponse@2(VAR Variant@1000 : Variant;ResponseWorkflowStepInstance@1001 : Record 1504;xVariant@1004 : Variant); ... ELSE BEGIN OnExecuteWorkflowResponse(ResponseExecuted,Variant,xVariant,ResponseWorkflowStepInstance); IF NOT ResponseExecuted THEN ERROR(NotSupportedResponseErr,WorkflowResponse."Function Name"); END;So here the Event OnExecuteWorkflowResponse is raised and then ResponseExecuted is checked and if not TRUE, an ERROR is raised.
[Integration] LOCAL PROCEDURE OnExecuteWorkflowResponse@47(VAR ResponseExecuted@1000 : Boolean;Variant@1002 : Variant;xVariant@1003 : Variant;ResponseWorkflowStepInstance@1001 : Record 1504); BEGIN END;
One after the other, each subsequent handler getting the returned value from it's predecessorSo, because the event can have multiple subscribers, how is VAR ResponseExecuted handled by the event,
Yes, it doesdoes ExecuteResponse get back the answer of the subscriber that happened to be called last?
No, not by the system. But Yes, by the way each subscriber is supposed to treat the ResponseExecuted parameter (see my comment above)Are the result of all the subscribers processed in some way (for example ORed together)?
So, since the system does not consolidate the answers from multiple handlers, the answer to the first part of that question is: nowhere (or maybe: in the handler's code). The answer to the second half of this question is: As far as I know nowhere apart from by example of the code in the standard NAV application.If so, where does this happen and / or where is the behavior defined / documented?
Answers
For example - this is my own handler subscribing to ExecuteResponse:
The event is raised with some specific value in Function Name, and if the subscriber handles that specific code it sets the ResponseExecuted. If the value in Function Name is unknown (no line in CASE statement matches it) the ResponseExecuted will not be updated - and if there is no other subscriber who 'knows' the function code then the standard code will throw unhandled response error.
When OnExecuteWorkflowResponse event is raised with specific function code it expects that some subscribers will handle it, and confirm this by updating ResponseExecuted.
It works OK even if you have more than one subscriber. You should handle specific function only once, but nothing stops you to have many supscribers to the OnExecuteWorkflowResponse, and some of them handling the same Function Name. All will work as long as you set the ResponseExecuted at some point (in one of the handlers).
The recommended flow is: if you take out Subscriber 2: here the SomeFunctionA is not handled at all and the C1534 will throw an error after last subscriber has finished its code
If you have extra Subscriber 4 also knowing "SomeFunctionA" : In the case above you may also decide that since ResponseExecuted passed from previous subscribers is TRUE, indicating that the "SomeFunctionA" has been already handled, you do nothing - like here
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Thank you for your answer.
At first, I did not consider a very obvious way of handling what I asked for in my question "Are the result of all the subscribers processed in some way". The obvious answer is:
The subscribers are called in sequence, and the next subscriber receives the result of the previous one.
In this way, the result is the logical OR of all subscribers IF (and only if) only the one that processed the event sets the flag to true. Any subscriber that does not handle the event must not set it to false.
Although Slawek_Guzek's Answer was helpfull, it was not complete.
Also my comment might have been not all that clear and did not really answer all my initial questions.
So here we go: One after the other, each subsequent handler getting the returned value from it's predecessor Yes, it does No, not by the system. But Yes, by the way each subscriber is supposed to treat the ResponseExecuted parameter (see my comment above) So, since the system does not consolidate the answers from multiple handlers, the answer to the first part of that question is: nowhere (or maybe: in the handler's code). The answer to the second half of this question is: As far as I know nowhere apart from by example of the code in the standard NAV application.