Dynamics Business Central / NAV Developer Digest - Vol. 475
ArcherPoint’s Developer Digest focuses on Microsoft Dynamics 365 Business Central and Dynamics NAV development. This week’s volume includes using TransferFields with FlowFields, using telemetry for API timeouts, the new TableKey module, and the Developer Tip of the Day.
The Dynamics 365 Business Central community comprises professionals devoted to advancing the success of their customers. Developers, project managers, and consultants collaborate to share helpful information across blogs, forums, and social media sites. From discovering new solutions to finding answers to complex issues, these dedicated individuals are constantly sharing their knowledge with others. At ArcherPoint, we recognize and appreciate this highly engaged community’s creativity, hard work, and collective intelligence. To ensure all users can benefit from their expertise, we want to share their wealth of information with everyone.
TransferFields will NOT CalcField the FlowFields
Yann Saint-Laurent posted:
Hi Everyone, I was asked to ensure the Sales Header Archive and Sales Line Archive had all the same fields as the Sales Header and Sales Line respectively.
While adding the missing fields to the Sales Header Archive, I came across an interesting dilemma: Should I recreate the flowfields as flowfields or let the system copy the values in the Sales Header flowfields to a static field on the Sales Header Archive. If the data is stored in the lines or comments, I know I can access it. But the idea of writing it a static value was appealing in an Archive Table.
After doing enough testing, I concluded that the TransferFields will NOT CalcField the FlowFields, it just skips them altogether. The only workaround we could come up with was to subscribe to the OnBeforeSalesHeaderArchiveInsert and populate each of the fields I wanted. This is an acceptable alternative, but any other developer who comes after us will also have to know to update the list of fields or write a routine that tries to do it dynamically using FieldRefs.
Have anyone done anything like this before? Would love to know how you handled it.
Helle Madsen replied: Base Nav/BC creates flow fields on the archived tables to match the original flow fields. Probably a safer way to do that for any customization as well.
Christine Henderson commented: Regarding missing fields in the archive table, we actually have an automated test that checks each of our Order tables against their archive version to see if all of the same fields exist in both tables. If someone adds a field to the regular table and forgets to add it to the related archive table, the test will fail during the build validation. No more missing fields!
Elyes Ferchichi added: I don’t trust the TRANSFERFIELDS function 100%. It’s based on the stored field ID that must match the same ID in the other table (not sure how it works with namespaces, I assume it is based on the field’s name). Since FlowFields are calculated data, you will not see any of the FlowFields fields in the SQL table. You must create them in your code (Archive table or other…)
API timeouts and telemetry
Speaking of FlowFields, Duilio Tacconi tackles the issue of uncovering the cause of an API timeout following the most recent Business Central upgrade. Using telemetry, he was able to isolate the API and the cause: Using FlowFields in queries.
Learn more by reading his blog, Incoming Web Services and API Query : a lesson learned.
New in BC 2024 Wave 1: Enable/Disable table inidices
Coming in Dynamics 365 Business Central 2024 Wave 1 (for on-premises only) is a new method in the Database object, AlterKey, that allows you to select a non-clustered index and enable or disable it
In addition, Microsoft is introducing a new Table Key module in System Application that provides a codeunit for disabling and re-enabling table indices.
Stefano Demiliani explains the benefits and limitations of these upcoming features in his blog, Dynamics 365 Business Central: introducing the new Table Key module.
Developer Tip of the Day: App Updates
Kyle Hardin posted: It is important that when your BC SaaS environments are ready to upgrade to a newer major or minor release of BC that you also update the installed apps at the same time. You can set this in the BC SaaS Admin Portal > Apps Update Cadence.
Interested in Dynamics NAV and Business Central development? Be sure to see our collection of NAV/BC Development Blogs.
Read “How To” blogs from ArcherPoint for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.