ArcherPoint Dynamics NAV Developer Digest - vol 272
The NAV/BC 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 experts and devotees around the world. We hope these insights will benefit you, too.
Triggers in D365 Business Central
Kyle posts on Yammer: “Has anyone else seen that even if you do Record.Insert(false), Business Central Still fires the OnBeforeInsert and OnAfterInsert triggers?”
Matt T. responds: “That is by design. The event subscribers have a parameter that is passed, named Retrigger. If you only want the code in your subscriber to execute when Insert(true) is called, you need to stick ‘If not RunTrigger then exit’ at the top of your subscriber.”
Kyle is adamant: “This. This is why Yammer attendance should be mandatory. Not only did I learn something important, but Matt fixed my customer problem, too. Keep caring and sharing, mad ArcherPoint peeps…”
Bill W. adds: “If not RunTrigger then exit’ should probably be the default based on this Vjeko post on OnTable Event Subscriber Patterns and Antipatterns.”
Saurav adds: “In upgrades, when subscribing all table trigger events other than Rename Trigger, developers need to have this line mandatory: ‘if not RunTrigger then Exit’. We faced this issue early on with upgrades and also did code corrections for add-on partners to add the first statements when they subscribe to these events.”
Dynamics NAV 2018 Record Locks
Faithie asks: “In NAV 2018 is there ANY way to tell who is producing a record lock? One client has them on occasion, and when they do, it becomes a proverbial train wreck! Please and thank you!”
Bill W. helps out: “See this article on SQL Server Extended Events to Produce a Blocked Process Report. You won’t be able to see the user, but you’ll be able to see the process. Turn on the feature in SSMS. Instead of creating the extended event report, I go to SQL Profiler and choose the ‘blocked process report’. You’ll see the SQL statements of the blocking and blocked processes.”
A Helpful Tip When Using Word as the Default Layout when Creating an AL Report
Ryan provides a helpful tip: “If you create an .AL report that uses a DefaultLayout of Microsoft Word, and that report name has spaces, you can’t use that same .docx file to import a custom layout in Business Central. I created an .AL report with a default layout of Word, and it created my .docx for me. I then edited the .docx, built, and published the app. The app was published to the sandbox. Now, I want to make some changes to the Word layout, so I took the original .docx and changed a few things. However, when I tried to import the layout in the sandbox, I got an error. Here’s why:
When you build the app, it will create the .docx for you, using the report name in the template. However, when you export a custom layout, it will replace the spaces with underscores. It’s not a big deal if you remember to export the custom layout first, and then edit it before importing it. I just spent a certain amount of time editing the original one, which now I need to do again (you can’t copy and paste the content controls).”
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.