microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
770 stars 610 forks source link

Codeunit 12 Gen. Jnl.-Post Line - ExchangeAmtLCYToFCY2 #2949

Closed lv-janpieter closed 5 years ago

lv-janpieter commented 5 years ago

We would like to have the function 'ExchangeAmtLCYToFCY2' to be 'global' and 'external'. Many thanks.

lv-janpieter commented 5 years ago

This is labeled as 'Ships in future update' however it isn't changed in CU2 or the daily build. I will issue a new ticket.

RomanZanizdra commented 5 years ago

Hi lv-janpieter. Just a very short question. How are you going to use this function from extension? It has several variables inside which are global and cannot be set from extension.

lv-janpieter commented 5 years ago

Hello RomanZanizdra,

Good question. In issue #2948 you have added the include sender to the publisher OnPostGLAccOnBeforeInsertGLEntry. We integrate with this trigger and if i'm correct I can use this function with the instance I receive from the publisher. I realize the function is of no use when I spawn a new instance of CU12, however this is not my intend.

I first intended to recreate the function however because I'm missing all the global variables this seemed impossible to me so in my opinion it is easier and more generic to have this function accessible.

Kind regards, Jan Pieter

RomanZanizdra commented 5 years ago

Hi Jan. Thanks for your reply, now it's more or less clear. I'm afraid the approach you described and try to use is no good for the following reason. You/we based on the assumption that all required functions that sets/gets/reads global variables required for calculation are called and the order of them is not broken. If something is changed that will lead to globals are not set correctly then amounts will be calculated incorrectly. And because some functions for globals are local and we can use them without fear to break something that can lead to undesirable consequences. The ideal case is to pass all required parameters to the function but at this moment we don't consider this case.

lv-janpieter commented 5 years ago

Hi RomanZanizdra. Thanks for elaborating. I understand your point of view. And I see over the past period you are trying to reduce usage of global variables to reduce these kinds of problems which in my opinion is a wise thing to do.

I discussed this issue with a consultant and we now believe that it is not that hard to recreate this function for ourselves.