ArcherPoint Dynamics NAV / Business Central Developer Digest - Vol 334
In this edition of Developer Digest, we discuss whether upgrade codeunits run when publishing an app to a Docker container and when to use the Clear function.
The Dynamics NAV and Business Central community, including the ArcherPoint technical staff, is made up of developers, project managers, and consultants who are constantly communicating, with the common goal of sharing helpful information with one another to help customers be more successful.
As they run into issues and questions, find the answers, and make new discoveries, they post them on blogs, forums, social media...so everyone can benefit. We in Marketing watch these interactions and never cease to be amazed by the creativity, dedication, and brainpower we’re so fortunate to have in this community—so we thought, wouldn’t it be great to share this great information with everyone who might not have the time to check out the multitude of resources out there? So, the ArcherPoint Microsoft Dynamics NAV Developer Digest was born. Each week, we present a collection of thoughts and findings from NAV/BC experts and devotees around the world. We hope these insights will benefit you, too.
Upgrade Codeunits Running When Publishing an App to a Docker Container
Kyle asks: “Do upgrade codeunits run when you publish an app to a Docker container?”
Suresh responds: “Yes, it will run when you publish it.”
Len adds: “There is also a setting you can put in your launch.json: forceUpgrade: true.”
Figure 1 – Setting in docker container for running codeunits
When to Use the Clear Function
Len inquires: “On a curiosity side, how many out there use the "Clear()" function regularly? For records, I love it; it does a clear and an init. Things like boolean, text, code, integer, decimal, etc., I still use it all the time. A long time ago, I had someone tell me not to do that; it should only be used on records. This was WAAAAY back when. But, for instance, if I want to clear several vars, I will write:
as opposed to:
BoolVar := false;
IntVar := 0;
Just curious what everyone thinks?”
Matt T answers: “I have never used Clear on anything other than a record variable. I actually didn't realize that it did an Init as well.”
Kyle adds: “The only things I use Clear with are records, arrays, lists, reports, and codeunits when I want any and all global variables reset inside those objects. I am also careful to close, dispose, and Clear any dotnet objects. Simple data types I set to zero, or space, or whatever the equivalent of null is.
Suresh continues: “I use it sometimes on the variables, and I have also used ClearAll in XmlPorts, and if you want to delete data from the blob or media field, then Clear is the way.”
Denise adds: “I use Clear a lot for records and variables. But I didn't know it did the init, so that's good info. TY!”
Kyle adds: “Keep in mind that there are performance reasons for why Clear, Reset, and Init all exist:
- Clear removes all filters regardless of filtergroup, sets each field to null, blank, or zero as appropriate, and then sets Init values for fields if that InitValue property is set for that table field.
- Reset removes all filters regardless of filtergroup but does nothing to any values in the record.
- Init sets each field to null, blank, or zero as appropriate and then sets Init values for fields if that InitValue property is set for that table field but does nothing to any filters that are set.
So, you as a developer should still be mindful of which of these commands is most appropriate and most efficient for what you are trying to do. You shouldn't go around hitting everything with a large Clear hammer.
Said another way, when your only tool is a hammer, all problems become nails.”
If you are interested in Dynamics NAV and Business Central development, be sure to see our collection of NAV/BC Development Blogs.
Read the "How To" blogs from ArcherPoint for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.