Tip #59 | Multiple Start Configurations in Visual Studio Code

When developing extensions for Business Central you have a wide array of publishing options to choose from.

My most used options when working on the ForNAV Customizable Report Pack are our Sandbox and Docker.

Testing is best on the Sanxbox for two reasons. First because all the Azure Active Directory stuff actually returns something which is useful for licensing scenario’s. Second because you can easily share the result with the team since everyone is on the same Sandbox.

Docker is useful when you don’t want to test on current but on an older or vNext instance.

Lastly it’s also possible to install Business Central on your own infrastructure altough this is a dying species.

In your Visual Studio Code project you can specify how you want to publish in the launch.json file but did you also know you can setup miltiple configurations and then choose one at the time of publishing.

This is how it could look:

{
     "version": "0.2.0",
     "configurations": [
         {
             "type": "al",
             "request": "launch",
             "name": "Docker",
             "authentication": "UserPassword",
             "startupObjectType": "Page",
             "breakOnError": true,
             "launchBrowser": true,
             "server": "http://bcsandbox",
             "serverInstance": "NAV",
             "enableLongRunningSqlStatements": true,
             "enableSqlInformationDebugger": true,
             "schemaUpdateMode": "Synchronize"
    },
    {
        "type": "al",
        "request": "launch",
        "name": "Microsoft cloud sandbox",
        "startupObjectId": 6188475,
        "startupObjectType": "Page",
        "breakOnError": true,
        "launchBrowser": true,
        "enableLongRunningSqlStatements": true,
        "enableSqlInformationDebugger": true,
        "schemaUpdateMode": "Synchronize"
    }
] 
}

Now if you publish your code Visual Studio Code will ask for the correct configuration.

NOTE: Your credentials cache is shared accross these configurations. You will need to clear the credentials cache if you switch.

TIP: You can also use this to create a seperate config for Syncronize and Recreate.

Tip #47 | Understanding PowerShell resultsets

Whether you like it or not, if you want to be a succesful Dynamics NAV developer in the future you have to understand PowerShell. So do I.

Currently I am working on an integration project where we make an interface between an external solution and NAV using WebServices. Idea is to ship the software with Delta files instead of a fob.

So I am running my PowerShell and notice some differences between NAV2013R2 and NAV2015.

This is what I run:

NAV2013R2:

$MergeResult = Update-NAVApplicationObject -Target “C:\Users\Marije Brummel\Documents\DynamicsNAVNA71\Files\” `

-Delta “C:\Users\Marije Brummel\Documents\Delta\” `

-Result “C:\Users\Marije Brummel\Documents\New Object\” -Force

NAV2015

$MergeResult = Update-NAVApplicationObject -TargetPath “C:\Users\Marije Brummel\Documents\DynamicsNAVNA80\Files\” `

-DeltaPath “C:\Users\Marije Brummel\Documents\Delta\” `

-ResultPath “C:\Users\Marije Brummel\Documents\New Object 80\” -Force

As you can see the parameters have changed, but so has the resultset.

Unfortunately there is not much documentation on the resultset, only on the cmdlet parameters.

But I ran into a video from Bas Graaf taht shows this:

$MergeResult | Get-Member

This returns a list with the object members.

NAV2013R2:


Name         MemberType Definition
—-         ———- ———-
Equals       Method     bool Equals(System.Object obj)
GetHashCode  Method     int GetHashCode()
GetType      Method     type GetType()
ToString     Method     string ToString()
Conflict     Property   Microsoft.Dynamics.Nav.Model.Tools.ApplicationObjectFileInfo Conflict {get;}
Error        Property   Microsoft.Dynamics.Nav.Model.Tools.ErrorInfo Error {get;}
Id           Property   int Id {get;}
ObjectType   Property   string ObjectType {get;}
Result       Property   Microsoft.Dynamics.Nav.Model.Tools.ApplicationObjectFileInfo Result {get;}
UpdateResult Property   Microsoft.Dynamics.Nav.Model.Tools.UpdateResult UpdateResult {get;}

NAV2015:


Name MemberType Definition


—-        ———-   ———-
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()
GetType     Method       type GetType()
ToString    Method       string ToString()
PSPath      NoteProperty System.String PSPath=C:\Users\Marije Brummel\Documents\New Object 80\COD84001.TXT
Conflict    Property Microsoft.Dynamics.Nav.Model.Tools.ApplicationObjectFileInfo Conflict {get;}
Error       Property     Microsoft.Dynamics.Nav.Model.Tools.ErrorInfo Error {get;}
Id          Property      int Id {get;}
ObjectType Property string ObjectType {get;}
Result      Property Microsoft.Dynamics.Nav.Model.Tools.ApplicationObjectFileInfo Result {get;}
UpdateResult Property Microsoft.Dynamics.Nav.Model.Tools.UpdateResult UpdateResult {get;}

So as you can see (I hope) the Path is missing in NAV2013R2.

What I ended up doing is using the NAV2015 cmdlet for NAV2013R2 objects. There is probably a smart way to figure out a filename from the other properties.

Challenge for someone?

Marije

Tip #44 | First time PowerShell, enable Scripts

This post is more a reminder for myself, each time I run into this when installing NAV on customers machines I have to search for the command.

I love modern development, PowerShell, TFS, etc. But it does not make life easier to understand all these technologies.

When running PowerShell on a new machine you might encounter this error:

PowerShell Script Disabled

It is telling you that PowerShell scripts are disabled.

Enabling is easy by running the Windows PowerShell IDE as administrator and executing this:

PowerShell Script Enabled

Works for me. After this I can work with the Development Commandlets.

Tip #43 | Search

Every now and then it happens. I get the feeling I am the only one not knowing a trick. Off course I realise that is not the case so I share what I learn.

MenuSuite and Search

As you might know or should know, the MenuSuite object is used for the search in Dynamics NAV.

Search1

This is the reason why you see almost a dozen instances of Navigate when you search it. It has been defined in the MenuSuite at as many places as that.

Search Criteria

So far nothing new for me. However I was watching How Do I videos this weekend from Claus Londstrom and Alexander Totovic when I noticed them typing in this:

Search2

If you type in “rep sel sal” it will search for words containing these words. This was the thing I did not know and wanted to share.

Enjoy.

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!

 

Tip #40 | Maximum on Promoted fields on Fasttab

Ok, I admit this is not a tip, but information I found out today and could not find anywhere in documentation.

I am upgrading one of my longer running customers to NAV2015 (eventually). So one of the tasks is to make pages for these creative forms with many fields.

I thought to be smart and save some real estate by promoting a fast tab with a lot of flags. I had 8 flags, so I expected a fasttab with 8 occurances of Yes or No.

2014-12-12_18-10-20

Instead, there are only 5 promoted fields. (Nee means No in Dutch).

So I started experimenting, searching on internet and testing in 2015, since I am making the pages in 2009R2 for a hybrid phase.

It seems that there is a limit of promoted fields on fasttabs to 5. Don’t ask me why. Must be something someone thought make sense as a decision for the entire NAV community.

So, Microsoft: Please remove this limitation, or at least make it like 10 or so.

Tip #39 | Pipe Filter with Excel | Alternative

I just looked at the video by Kerry Rosvold on how to make a pipe filter in excel. It’s awesome. You can watch it here.

Now, I have an alternative way that I have been using for the last many many years and I don’t understand why I never shared it.

Blogging it now kinda make me a smart-ass. Maybe I am that. I apologize. 😉

So this is how I do it.

You copy a few lines to excel like this:

2014-12-04_20-25-50

And in Excel you paste, and copy the number column

2014-12-04_20-27-37

And you paste/transpose and copy the results again

2014-12-04_20-29-07

Then you open a notepad, paste the rows and copy the tab character

2014-12-04_20-30-17

Then you select find/replace, paste the tab character and replace with the pipe sign

2014-12-04_20-31-31

There you have your filter.

Now you have two options. Maybe there are more.

Thanks again Kerry!

NAV 2013 R2 | Debugger Watches

I totaly love the concept of pages. They are easier to merge and upgrade and they way they render is awesome. However, they come with a few drawbacks. Some of them we already had in the classic client with forms, some are new.

One of the drawbacks is the lack of drag and drop. This was true for the classic client too.

A place in Dynamics NAV where it is very obvious what would be the value of drag and drop is the debugger. The debugger in NAV2013(R2) is designed as a page.

Like this:

Dynamics-NAV-Debugger-2013-1

In general it works pretty good. It is easier to break, toggle breakpoints and the fact that you can debug any user on the servicetier is just straigt from heaven.

But one of the things that was a 1000 times easier in the old debugger was watches. It is no longer possible to just drag and drop them.

However… I only recently found a neat trick and I figured “how is it that I did not notice this earlier”.

The AL codepart is developped as a client add-in which allows to send events to the page. One of the events is adding a watch while hovering over a variable like this:

Dynamics-NAV-Debugger-2013-2

Now take a close look at the icon

Dynamics-NAV-Debugger-2013-3

If you push the + sign the variable is added to the watchlist.

Personally I find myself pretty foolish not noticing it for more than like 2 or 3 years but hey, I might not be the only one.

Here is the event in AL:

Dynamics-NAV-Debugger-2013-4

Enjoy