Friday, August 9, 2019

How to handle changes in NAV/BC when event does not exist ?

questions-4304981_1920

In the NAV2018/BC we are using AL for development and build extensions for our customizations using table/page extensions and events.  But in NAV 2018  and also in BC on premise versions there are certain cases where we don’t find the event to subscribe, in that case how should we handle the modification ? and avoid any conflicts in the next upgrade.

In those scenarios, should we modify the base objects like the old way ?

Sometimes events even get trickier. Such as I want to exit from a calling function without executing the next line of code, after the event is executed ? This is not possible unless you design the event in that way. In this case, the event should have a variable as parameter, which we set in the subscriber function based on our condition, and if that is true, in the calling function there is already a code added to check that value and exit. Everyone has a unique requirement, so designing events this way is little harder. I think in the future the events may evolve where we will have a way to define that. Anyhow, I ran into this kind of situations only couple of times.

The real question is how we handle the modification when there is no event available to subscribe. This is the procedure I am following and sure there are better ways to handle it. I usually check if the same object in the newest cumulative update or in the new version, if there is any event added, then I try to copy that and update the object in our version, that way it will not create any conflict during the upgrade.

For example, I have a created a new field on the Ship-to Address and Sales Header table called “Locality”, so when a ship-to code is selected, I want to transfer the Locality value from the respective Ship-to Address table to Sales Header. In NAV 2018 version CU 14, I don’t have any events available to subscribe to transfer the value, but in the newest version I found this event “OnAfterCopyShipToCustomerAddressFieldsFromShipToAddr”

 

image

I have just copied over that event from the new version to my version. Then in my extension, I have created a subscriber Codeunit and subscribed to the function. 

If I don’t find a event, then I will create my own event, and try to name it properly, following the standards MS is using that way in future version if they add anything it may reflect. Also suggest/ask the product team in the below link

https://experience.dynamics.com

Share:

4 comments:

Chris said...

Pretty great, I'll try to follow this later

Nian Zhen said...

Nice Blog

Nian Zhen said...

Navision is also known as Microsoft Dynamics 365 Business Central nowadays which has two modules; Dynamics 365 Business Central Essential & Dynamics 365 Business Central Premium.
Want to know more? Visit our website.

tareeqrachlin said...

Casinos near me - Casino Junk
Search for Casinos 천안 출장마사지 Near Me Near Me · Hollywood Casino 대전광역 출장샵 At Kansas Speedway · Casinos 안산 출장마사지 Near 아산 출장마사지 Me 서울특별 출장안마 · Hollywood Casino At Kansas Speedway · Hollywood Casino At Dayton