Tip #42 | SetCurrentKey on Flowfields

I’ve already posted a few times about the possibilty of doing SETCURRENTKEY on non key (indexed) fields and doing flowfields and CALCSUMS on non SumIndexFields.

Another option that we have is to do a SETCURRENTKEY on a flowfield.

For example:

2015-01-31_21-07-28

This will give the following result:

2015-01-31_21-09-31

And we can check that this is correct:

2015-01-31_21-09-09

Be careful. Mind performance.

Enjoy.

Tip #41 | Smart Page Address Formatting

Ok, enough about these Design Patterns. Time for a real tip you can start using in 3 minutes.

We all know that pages use more real estate than classic forms and we are limmited to two columns. Putting two controls side by side in one column is cumbersome.

One of the things I run into a lot since I do many logistics customers (TMS) is addresses on pages. When not on Master Data you are typically not allowed to change them.

Address fields take up a lot of space, like here:

2015-01-28_20-36-03

We need up to five elements to display an address. What if I tell you how to show it like this:

2015-01-28_20-29-40

It is extremely easy. An address uses the room of less than 2 normal fields.

Step 1 – Add Function to Source table

Like this:

2015-01-28_20-30-05

Here we return the address with a cariage return and line feed between the address and the Post code. You can make this smarter off course.

Step 2 – Add Function as Control with MultiLine property

Like this:

2015-01-28_20-30-38

And voici, you are good to go!

 

[PRS] Design Patterns that should be [made] obsolete [by Microsoft]

Yes, this blog has a double title. Every now and then you need to do a little self reflection. Two weeks ago I was in talking with my fellow PRS member Soren Klemmensen and we discussed the fact that in the list of object oriented Design Patterns that we brought to Dynamics NAV there are a few that could be built in or better integrated if Microsoft would help us a little.

Ok, if you read this and think, what does this guy mean, then I should tell you some background first, otherwise just skip this part.

For the last 4 or 5 years ago we have been working on the Design Patterns project. Next to documenting the existing patterns with Microsoft we also tried to look at some best practices to better code in Dynamics NAV. They are also design patterns, categoriesed as implementation patterns, meaning the way you structure code.

Examples of these patterns are:

  • Class, Method, Property (aka Agents/Actions)
  • Natural Language Programming
  • Encapsulation
  • Facade
  • Hooks
  • Interfaces
  • Surrogate Keys

You can learn more about these patterns on my YouTube channel.

While most of these patterns have nice names now, we actually changed them quite a number of times. Natural Language Programming was once called Readable Code and Encapsulation was called Atomic Coding. The Class, Method Property has two names as well. Reason for this is that we learned during the project that most of these concepts are well known in computer science and object oriented programming. We were reinventing wheels.

Dynamics NAV has a realtively basic development environment that does not allow us to do things that Visual Studio and C# or other languages do. On the other hand it has lots of things that C# does not have that we can take advantage of.

This can come in handy when trying to make a couple of these PRS design patterns obsolete, smarter or built in the environment. One of the reasons we can do this is becuase C/AL and C/SIDE are very metadata driven.

So what patterns can be made obsolete

Class Method Property (aka Agents/Actions)

This pattern teaches us to make all functions that you can perform on a table a member of the table and if complex enough put inside their own codeunit.

The reason why we thought of that is actually a bug in the symbol menu. The symbol menu does not understand code outside the contect of the variable you define. For example: if you define a variable of the type Sales Header, it does not show that we have a codeunit that takes this record as a parameter and posts it.

If that would be the case, we would probably have to rethink this pattern. I have implemented this pattern at one of my solutions where we have a table that is more or less the core of an application. This table now had douzens and douzens of functions. I can honestly say that this does not improve usabilty more than loosely coupling the codeunits to tables.

It would be easier if NAV reads the metadata and helps with the symbol menu. That would save a lot of functions on the table that are then obsolete and actually a hassle to maintain.

Facade

This was the example I thought about yesterday when I did an introduction to design patterns workshop for NAVUG USA. I was talking about encapsulation and override. Most languages allow programmers to override functions in a class. NAV does not.

With PRS we found Facade as a solution for that, but it is actually wrong to suggest to implement a facade for each function you create on the table. Think about it. You would dramatically make your code more complex than required.

Facade is a great pattern! It exists in object oriented world and it should be implemented by design if the architect expects functional requirements to override the function. The typycal example is weighing bridges where every customer has their own hardware and has a custom interface. This is what facade does great.

C/AL should allow programmers to override any other function at design when required without the orriginal architect anticipating every move. Other programming languages allow that.

Surrogate Keys

This is the newest member of the PRS design patterns and as most other patterns it started its life with another name. Unique Record Identifier.

In dynamics NAV most tables are connected through the primairy key, for example comments. Comment tables have complex primary keys to be able to connect them to each table in NAV.

The idea is to add a single unique key to each table in NAV so we can connect to other tables using a single unique key. Think about the possibilities to add factboxes using this to each table in NAV without thinking.

C/SIDE can add this automatically for us.

Conclusion

Some design patterns can be improved with what I think are relatively small changes to C/Side. We should always self reflect and realise that some things we do are actually workarounds.

Windows 10 and Dynamics NAV | Continuum and ERP

As I am writing this blog, Microsoft is showing Windows 10 to the world. I have always been a Windows fan and worked with the very early releases back until Windows 1.

Windows10-1

When Windows 8 was introduced we quickly got some screenshots emailing aroundhow the new “Live Tiles” would influene Dynamics NAV.

In reality this never happened. Live Tiles failed as people did not like the big bathroom interior on their desktop experinece and NAV never adopted the possibilty of showing data on the tile.

A big mistake still if you ask me, also considering that it looks like with Windows 10 we will still have the tiles as part of the start menu. I love the tiles and the fact that it shows me stuff without opening the application.

We got tiles in Dynamics NAV in the Role Center, with sentiment. I love that feature. I would still like to be able to make these bigger or smaller like in Windows 8 and put more on them like images and text.

But that is not what I wanted to write. Get to the point I hear you think.

Continuum

What is that, I hear you say. It means that each device that runs Windows can run the same apps and adopts to the device. If you have a small device without keyboard and mouse it optimises for that, if you run on a tablet you get more real estate and if you attach a keyboard it automatically optimises again. Like in this video:

I would love to see this feature adopted in Dynamics NAV. We already have an app for tablets, what if that would be cross-device and works on all devices? Adopting to keyboard if required.

Please Microsoft! Make this work. And while you are at it, please use the live tile to display information. Like the number of Workflow alerts from your roadmap.

Dynamics NAV should have the best Windows 10 experience of all ERP products out there. We have the architecture to make it happen.

Microsoft Convergence Atlanta 2015 | My Sessions & Workshops

Convergence 2This year in Atlanta I will be attending Convergence for the first time in many years. I am really looking forward to go back to this great event.

I am also speaking at two sessions for this event as part of the sessions delivered by NAVUG.

Ask your peers: Reporting with Microsoft Dynamics NAV and Word – really!

Would you like to get up-to-speed on Microsoft Word reporting for Microsoft Dynamics NAV 2015? In this session, we’ll discuss the user-friendly and powerful setup options, layout and formatting possibilities, and report scheduling and notifications. We’ll also show you the exciting Jet Add-in that greatly simplifies using the dataset from Microsoft Dynamics NAV. After spending a little time with us, you’ll be ready to do it yourself! This session is presented by NAVUG/MVPs.

Ask your peers: Upgrading Microsoft Dynamics NAV – myths and facts

When upgrading to the latest and greatest, everyone is faced with challenges. You are not alone! How do I determine budget? Am I dependent on vendors? Will there be downtime? What about existing hardware and peripherals? Do I need to upgrade SQL Server? What about Microsoft Azure vs. on-premise? We’ll separate the myths and facts so you can proceed intelligently, and we’ll prepare you for questions to ask your partner to help you upgrade effectively. This session is presented by NAVUG/MVPs.

Design Patterns Worskhop

Are you visiting Convergence and curious about learning more about Design Patterns? Together with Mike Doster, Lead MCT, I am hosting a workshop in Atlanta the same week as convergence. On March 19th and 20th you can learn everything about design patterns and programming best practices in NAV.

The price of the workshop is 580 USD. You can register via this website. You can also use the contact form on this blog.

Here is a short intro video to the Design Patterns

See you in Atlanta!

Convergence 1

Design Patterns on Partner Source now!

We already have Design Patterns on YouTube, MSDN, Wiki and MiBuSo.

Now we can add Partner Source to that list. Microsoft has asked me to create an overview page and introduction video to the subject.

You can find the page here. (If you have access to Partner Source).

The introduction video has also been uploaded to my YouTube channel, where you can find a link to all Design Patterns videos, including the ones I’ve created about the Implementation Patterns.

Dynamics NAV vNext : Corfu

Ok, writing about a new version before it is released with a current NDA is like walking on eggs. It can almost only go wrong.

But, I am so exited about the upcomming release that I have to let that know to our community.

The reason for my exitement is the roadmap, presented by Microsoft on the events of fall last year. If you look at that roadmap you see a lot of functional areas. This is the first time in almost a decade that the list of new functional features is as long as it is for this release.

Let’s have a look at that roadmap.

2015-01-18_21-08-38

This screenshot is taken from the video of the NAVTechDays keynotes, but the other events showed similar announcements. I highly recommend watching the entire video.

The roadmap shows Workflow, OCR & Document Mgt and e-services integration.

There is another functional enhancement and I am 100% sure it was mentioned during an event, but I cannot find proof online so I won’t mention it here.

The future of NAV is looking bright. Adding functionality is so important for everyone.

C/AL Coding Guidelines | NAV2015

As long as I work with Dynamics NAV as a developer, coding guidelines have always been a point of arguments.

Long, long time ago they were published by Navision as part of the development training materials and documentation.

I know most partners have their own rules and standards, and Microsoft have them too.

They are published

The good news is that they are now updated and published by Microsoft!

You can find them on the Dynamics Community website. Here.

As part of the “How Do I” video series for Design Patterns in Microsoft Dynamics NAV I have also recorded a video.

Cyclomatic Complexity

One of the things I like most about the guidelines is Cyclomatic Complexity. This is a well known concept in computer programming and is now mapped for Dynamics NAV.

More information you can find here and here.

Implementation Patterns

While you are implementing these guidelines in your organization, remember to have a look at these implementation patterns. They are great to use and have a big return on investment.

Implementation Pattern #1 | Classes, Methods and Properies

Implementation Pattern #2 | Natural Language Programming

Implementation Pattern #3 | Encapsulation

Introduction to Design Patterns and Upgradable Code | Free Webinar

For the NAVUG Summit in St. Louis 2014 I did a presentation called Introduction to Design Patterns and Upgradable Code“. This presentation was very well received with top ratings. Therefor NAVUG have asked me to repeat the presentation in a webinar which is free for anyone to attend.

The Webinar is on January 27th from 21:00 to 22:00 CET (Europe) and 3:00 PM – 4:00 PM EST (US)

Here is the link

The session will be recorded too.

NAVUG_New-1_sm

NAV 2015 | Automatic Variable Naming

Evey now and then I have to let off some steam like in my previous post: Repeatability, Hype or Reality?

That does not mean that overall, the product is just awesome.

One of the features in NAV2015 I absolutely love is the automatic naming of variables.

In the last two weeks I started working on a new project with NAV2015 and its just amazing to see how quickly you get used to this feature as today I am working with NAV2009R2 and I miss it already.

It’s just one of these small things like “Go To Definition” that makes life so much easier.

Just in case you wonder: “What is this guy talking about?”

What is it

If you create a variable that refers to an object type in NAV such as Record or Codeunit the name populates automatically using a set of rules.

VariableName

The rules are quite simple, it removes all characters excelt alphanumeric and numeric characters.

Mini DataDictionairy

The feature basically allows a simple data dictionairy for variable naming. Its a small step towards a library of allowed names for objects, fields and variables.

Great job Microsoft!