Hi Readers,
As you might know, Online Business Central does not allow you to change the standard code just as NAV. in the sense that, whenever you wanted to add code to a trigger in NAV all we had to do was find the right place, insert your code and document the version. It doesn't work the same way in Business Central.
Now, what to do if we want to add some code on onValidate() of Customer Table or modify any other Object? How do we change the standard code? Is it even possible?
Well, all the questions will be answered in this blog.
If you have noticed, most of the NAV Tables have IntegrationEvent methods and these methods are called at different places wherever required.
Business Central has these Events as well. Whenever we have to modify standard code. We will create such Integration Events and modify the code by Publishers and Subscriber Events.
Confused?? Do not worry! We will consider a scenario and that will make things clear, so keep reading.
(Know about Events)
Task: We will create an IntegrationEvent (Publisher) in Customer Table and then call (Raise) this Event wherever you require it. Once we have both the ends ready, we'll modify the standard code (Subscriber).
Scenario: In Customer Table, trigger onValidate() of Name and display a message "I now know how to modify standard code!"
(This is a basic scenario for learning purpose. Make changes according to your Change Request using the same method)
Firstly, create a Publisher Event in the Customer Table. This is the IntegrationEvent that we spoke about:
Secondly, retrieve or raise onValidate() of Name in Customer table by using the same Table Extension:
Lastly, write the logic in an EventSubscriber. here I am creating a Codeunit as that whenever I want to modify Customer Table, I can extend the same Codeunit:
Implementation: A message will display after Name onValidate() trigger.
Note: If you already have Integration Events that you want to use. all you have to do is subscribe to it.
Interesting, isn't it? Try and let me know!
I hope this blog was helpful and knowledgeable. Please let me know what all blogs would you like to see!
Write your suggestions in the comment section.
You can also email me at jyotsnaoberainav@gmail.com
Also, visit my website JONAV if you need help with any NAV/BC Services!
Thank you!
As you might know, Online Business Central does not allow you to change the standard code just as NAV. in the sense that, whenever you wanted to add code to a trigger in NAV all we had to do was find the right place, insert your code and document the version. It doesn't work the same way in Business Central.
Now, what to do if we want to add some code on onValidate() of Customer Table or modify any other Object? How do we change the standard code? Is it even possible?
Well, all the questions will be answered in this blog.
If you have noticed, most of the NAV Tables have IntegrationEvent methods and these methods are called at different places wherever required.
Business Central has these Events as well. Whenever we have to modify standard code. We will create such Integration Events and modify the code by Publishers and Subscriber Events.
Confused?? Do not worry! We will consider a scenario and that will make things clear, so keep reading.
(Know about Events)
Task: We will create an IntegrationEvent (Publisher) in Customer Table and then call (Raise) this Event wherever you require it. Once we have both the ends ready, we'll modify the standard code (Subscriber).
Scenario: In Customer Table, trigger onValidate() of Name and display a message "I now know how to modify standard code!"
(This is a basic scenario for learning purpose. Make changes according to your Change Request using the same method)
Firstly, create a Publisher Event in the Customer Table. This is the IntegrationEvent that we spoke about:
Secondly, retrieve or raise onValidate() of Name in Customer table by using the same Table Extension:
Lastly, write the logic in an EventSubscriber. here I am creating a Codeunit as that whenever I want to modify Customer Table, I can extend the same Codeunit:
Implementation: A message will display after Name onValidate() trigger.
Note: If you already have Integration Events that you want to use. all you have to do is subscribe to it.
Interesting, isn't it? Try and let me know!
I hope this blog was helpful and knowledgeable. Please let me know what all blogs would you like to see!
Write your suggestions in the comment section.
You can also email me at jyotsnaoberainav@gmail.com
Also, visit my website JONAV if you need help with any NAV/BC Services!
Thank you!
Very useful
ReplyDeleteThank you for your feedback.
DeleteMake sure you check other blogs too. Do share it across.
Have a great day! :)
its very useful.
ReplyDeleteThank you for your feedback.
DeleteMake sure you check other blogs too. Do share it across.
Have a great day! :)
This comment has been removed by the author.
ReplyDelete