Getting out of the DateTime mess, or how to get Utc DateTime in C/AL

  • Post comments:13 Comments
  • Reading time:5 mins read

Today at work I was trying to untangle one big bowl of spaghetti called DateTime. It’s the C/AL DateTime I am talking about, not System.DateTime from .NET.

The problem with C/AL DateTime is that no matter what you do it’s, according to documentation, “always displayed as local time”.

Another problem with C/AL DateTime is that C/AL is a bit rude when it comes to System.DateTime: whenever C/AL compiler (or runtime) encounters a value of System.DateTime it’s automatically converted to C/AL DateTime.

When you combine those two problems, you get the following problem: even though System.DateTime is perfectly capable of handling time in both UTC or local kind, C/AL isn’t.

To prove this point, just run this:

MESSAGE(‘Current local time: %1\Current UTC time: %2’,SystemDateTime.Now,SystemDateTime.UtcNow);

It will show this:

image

And I am currently sitting in a UTC+1 time zone, mind you.

(more…)

Continue ReadingGetting out of the DateTime mess, or how to get Utc DateTime in C/AL

Visual Studio Control Add-in Project Template

  • Post comments:23 Comments
  • Reading time:3 mins read

If part of your daily job includes creating control add-ins for Microsoft Dynamics NAV, then you know that creating control add-ins that target all clients requires quite a lot manual work. There are a lot of small steps that you must do every time.

To avoid all that work that adds no value, only frustration, here’s a Visual Studio project template that you can use to automate the process of creating a new control add-in.

(more…)

Continue ReadingVisual Studio Control Add-in Project Template

Deploying from Visual Studio, update

  • Post comments:1 Comment
  • Reading time:3 mins read

A few days ago I have published my PowerShell script that streamlines and automates deployment of control add-ins from Visual Studio. Over the past couple of days I have improved it a little bit, and fixed a few bugs, so here’s an updated version that is more resilient to your project structure, produces resource zips that NST not only extracts, but actually understands, and does a little more.

(more…)

Continue ReadingDeploying from Visual Studio, update

NAV TechDays 2015 wrap up

  • Post comments:6 Comments
  • Reading time:3 mins read

Another NAV TechDays is over, and this one was the best so far. 950 people from all over the world all passionate about NAV and technology and eager to learn and share and discuss the latest in NAV. It was amazing, Luc did a great job again, and I am looking forward to the next year, hoping this conference makes it beyond 1000 attendees.

This year I have delivered a yet another “Black Belt” session named “Client Add-ins Black Belt: bringing .NET and JavaScript together” and as promised, I deliver the session material here on my blog.

(more…)

Continue ReadingNAV TechDays 2015 wrap up

Out-of-transaction database writes

  • Post comments:7 Comments
  • Reading time:4 mins read

Ancient wisdom goes that you cannot have more than one write transaction going on at the same time in a single session in NAV.

This is absolutely true, in and out.

Some features, like Activity Log, will leave you wanting to be able to write to the database outside of the normally running transaction.

Wouldn’t it just be beautiful if you could:

  • Write to the database, and then persist the change to the database even if an error happens during the transaction? (without cough! TryFunction, cough! cough!);
  • Not cause any locks to remain at the target table for any longer than it takes to do the write itself, without having to call COMMIT on your “regular” transaction; and
  • Not use temporary tables, because a system error (however unlikely) could cause the data to not be persisted if crash happens before temporary table is flushed to the physical one.

Well, in fact, you can do this.

(more…)

Continue ReadingOut-of-transaction database writes