AL icon indicating copy to clipboard operation
AL copied to clipboard

External codeunits 1002 and saleslinies

Open clausmacali opened this issue 8 years ago • 3 comments

Need Thes to beExternal Function Visibility for the Function UpdateAmounts in the “Sales Line” table should be changed to External. Also there are events in the Code unit - 1002 - "Job Create-Invoice" that MS needs to change the Function Visibility to External, So that they can be invoked from Extension and if there any customization based on the events those will work without any issues.

clausmacali avatar Jun 07 '18 08:06 clausmacali

I will expose the UpdateAmounts function on the Sales Line table; no problem in that. However, I cannot expose the events in codeunit 1002. The events are local and are not supposed to be invoked out of context of that particular codeunit. You should be able to subscribe, obviously, but not invoke. E.g. OnBeforeInsertSalesHeader is an event, that is invoked before the sales header is instered in the CreateSalesHeader function. It would make no sense to allow invocation out of context of that function.

JesperSchulz avatar Jun 08 '18 11:06 JesperSchulz

Thanks Jesper We are changing the functionality so we cannot use the functions because we need to write code and logic in between. So we are creating new codeunit with the same code from Ms with our customization. And then we would invoke the events so if there are any subscribers it works without any issues..

clausmacali avatar Jun 08 '18 12:06 clausmacali

I see! Well, now I understand why you would want the events to be exposed :-) But I'm afraid that isn't the right way to achieve the desired result. By exposing events and functions, which should not be exposed, we are locking ourselves down, while we would be worsening the design of the application. We hence cannot do that. Is there any chance you could refactor your code so that you can add your changes through events and you wouldn't need to copy our code? Alternatively, could we completetly refactor COD1002 to make it extensible? We need a more sustainable solution, instead of allowing for patches which help us do workarounds, but worsen the overall design. I hope you understand where we're coming from... I will close this issue and hope you will create new one with event requests, which will unblock you.

Kind regards,

Jesper

JesperSchulz avatar Jun 13 '18 07:06 JesperSchulz