Dynamics Business Central / NAV Developer Digest - Vol. 454

Dynamics Business Central / NAV Developer Digest - Vol. 454

ArcherPoint’s Developer Digest focuses on Microsoft Dynamics 365 Business Central and Dynamics NAV development. This week’s volume includes two new features in BC 2023 Wave 2 – optimized data stack and SecretText data type, DateTime manipulation in Business Central, and more.

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.

New release feature: Optimizing the data stack in Business Central

The newest release of Business Central (Business Central 2023 Wave 2) will include a significant change in the data model for table extensions. Previous versions of Business Central created a new table for every extension (called companion tables), requiring the server to perform multiple joins for every extension. The latest release will change the data model so that fields from all extensions to a table in Business Central are combined into a single companion table, increasing performance.

ArcherPoint’s Saurav Dhyani shows how the new companion table data model works in Business Central and offers tips for how developers can leverage this change.

New release feature: SecretText

Business Central 2023 Wave 2 will include a new AL data type: SecretText. It can be used to protect the visibility of sensitive text (for example, credentials) from being seen during debugging.

SecretText can be used as a:

  • Variable value
  • Return value
  • Parameter value

SecretText has limitations, but it will help secure sensitive data and still allow easy troubleshooting.

Read Stefano Demiliani’s blog, Dynamics 365 Business Central: introducing the new SecretText data type, to learn more about this new data type.

DateTime Madness

From the musing of a frustrated developer:

I’m working on some code to process Outlook emails, and I needed to ask Outlook for all the emails since a certain DateTime.

I had already noticed that when I was saving the CreatedDateTime, which comes from the Graph API as ‘2023-09-07T16:57:54Z’, BC would interpret this DateTime as my local DateTime, then calculate the offset to UTC and save that as the DateTime value. I’m in Pacific Time, making the DateTime value offset by 7 hours as we currently are in daylight saving time.

Knowing the above, I started looking at ways to solve it. Interestingly, the TypeHelper Codeunit has some Functions that should help, but none returned the right values. For example, the TypeHelper.GetCurrUTCDateTime() just returned my local time. To make matters worse, Business Central does not seem to have any setting/understanding of Daylight Saving in its interface. If you go to Settings -> Time Zone, it currently displays (UTC-08:00) for Pacific.

Wanting to find a usable solution, I ended up having to code it as follows:

I start with the DateTime as Text. I evaluate it into a DateTime Var. At this point, the Var has the same DateTime as the Text var. Then, I format the DateTime Var. Interestingly, this returns the DateTime as text, but it has added 7 hours to it. It’s like BC assumes that when you are formatting a DateTime, you are starting with a local DateTime and want the UTC version as the EvalTextDate var gets set to 11:57 PM. So, with this, I turn the EvalTextDate back to a date value, which allows me to calculate the duration between the 2 DateTime -7 hours. Lastly, I have to remove 2x the duration as the last format will add the offset.

I’m sure this can be done in one or two lines of code, but it certainly should not be this convoluted.

startTextDate := '2023-09-07T16:57:54Z';
Evaluate(startDateTime, startTextDate);

EvalTextDate := Format(startDateTime, 0, 9);

Evaluate(EvalDateTime, EvalTextDate);

duration := startDateTime - EvalDateTime;

localDateTime := startDateTime + duration * 2;

outputDateTimeText := format(localDateTime , 0, 9);

Hope this helps others.

DateTime conversion output
DateTime conversion

Funny of the week

Kyle Hardin shared this all-too-true example of UI design:

UI design: Theory and application
UI design: Theory and application

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.

Trending Posts

Stay Informed

Choose Your Preferences
First Name
Last Name
Subscription Options
Your Privacy is Guaranteed