Custom layout crashes NAV after upgrade

Currently I’m upgrading a customer from NAV2015 to NAV2017.
During the implementation of NAV2015 the customer has asked me, I they could design there reports themselfs.

And my reflection was, why not.

So as said the customer changed there report layout within NAV with the feature “Custom Layouts”.
A new feature back in NAV2015 but still available in NAV2017.

Now during the upgrade of this customer I ran into some issues when testing the upgraded version.
Every time I try to print a report with a custom layout NAV crashes with no more information.

Continue reading  

Change default printer from CAL

A while ago Waldo has posted a way to print any document from CAL. Here he showed us how easy it is to print any document with any extension by simple using .NET.
Recently I used this to print merged PDF’s from CAL, but I ran into an issue.

I want to print this PDF’s on a certain printer.
Some products like Adobe cleams to support this by passing some parameters like:

AcroRd32.exe /t path “printername” “drivername” “portname”

But then you are related to specific software and what with the other extensions.
Do you realy want to create separate statements for every extension.
I don’t think so.

Thereby I search for a better way, and here it is.
Why don’t use .NET again to solve this issue.
Instead of passing the printer as a parameter, I will switch my default printer from CAL.

Continue reading  

“OnAfterObjectsChanged” Event

I think the following scenario will sounds familiar to every developer.

You develop a nice new feature with a couple of tables, pages and codeunits. These new objects needs to be imported in the production environment.

You make a fob file of all your objects or create deltas, import it in the development environment and compiles the objects. And maybe you need to restore the NST, but this is questioned many times. Some are saying this is mandatory but I doubt it.

Before your solution will work, you need to do some setup in every company by opening the pages and provide the right parameters. A very time consuming (aka monkey task) to do and if your head isn’t clear you can forget something or make mistakes.

Would it be nice if the system itself will know when there are objects imported and auto configure your solution? That the system will raise an “OnAfterObjectsChanged” event the first time you open a client after you imported you objects.

That is what I’ve created and I will share it with you in a moment.

The first part is to determine if there are objects imported to the system. As you properly know these are created and updated in the system table “Object”.
Now I need to know when this table is changed from within NAV itself.

First, I thought to use “OnAfterInsert, OnAfterModify or OnAfterDelete¬†Events” on this table, but these will not be raised from within the development environment when you import objects.

But then I come up with the following idea.

As you might know there is a field called “Timestamp” in every NAV table. This is maintained by SQL on every insert and update.
So, if I make a sum of all the timestamps in the “Object” table and compare it with a previous saved value, I know that something has changed and even that there are records deleted!

To get the sum of the timestamps, I used the following SQL statement and executed from within NAV itself.

Continue reading  

Avoid Factbox records on Empty pages

Factboxes are more then ever a powerfull way for presenting related information. Normally you link your Factbox through properties, but now and then you need to do this from code.

This works fine if your page has at least one record, because the filtering is set on the “OnAfterCurrRecord” trigger of the page. So when there is no records, no filter is set on you factbox and then all related records are shown. Continue reading  

A TableSyncSetup value Copy for old table cannot be specified when no new table exists

When upgrading a old NAV database you sometimes need to transfer data to new tables. With the Upgrade codeunits you can manage this easily.
First you make a TableSyncSetup function where you configure your transfer.
And then you make an UpgradePerCompany or UpgradePerDatabase function where you will do the actual transfer.

But recently I got the following strange error when deleting a table.

The system tells me that there doesn’t exists a new table???? Continue reading