Tag Archives: temporary

Tip #52 – Run MODAL pages after INSERT

One of the things I spend a lot of time on during my workshop is design for performance and using temporary tables. There are so many great things you can do here.

Let’s look at this code:

Buffer 1

Typically after an insert you would expect this error when trying a RUNMODAL

Buffer 2

But, not in this case. Here we have this:

Buffer 3

The reason why this works is the use of a temporary table. The record is not actually inserted into the SQL Server database.

Buffer 4

This is very useful for example when running a wizard. This allows you to roll back the transaction very easily when the wizard was cancelled.

Do you want to lean more?

During my workshop I spend a lot of time on these typical things in NAV that are poorly documented but very powerful.

The next workshop is in Copenhagen, close to the heart of NAV developement.

Register here. (QBS Partners can use vouchers)

Tip #27 – Using Temp tables in Arrays

Tip #27 – Using Temp tables in Arrays

I’ll be honest, I found this out by accident lately but I want to share it anyway. Since it took me almost 15 years to find, it might not be know to some others.

As many of you know, using temporary tables in Microsoft Dynamics NAV is a very powerfull feature. We can use it to buffer data, to simulate SELECT DISTINCT etc. And they are free.

Using temporary tables becomes even more powerfull when adding an array to it. Let’s see this in an example.

We’ll create a new codeunit with a variable CustTemp that has two dimensions.

So now we can use CustTemp[1] and CustTemp[2].

Let’s write some C/AL Code with this.

We create a new record using CustTemp[1]. We then try a FINDFIRST on CustTemp[2]. Let’s see what message we get.

How cool is this! The contents of the CustTemp[2] is the same as that of CustTemp[1].

So what can we do with this. Let’s add some more code.

We add a new record to CustTemp[2] and filter on this value using CustTemp[1]. Then we show the value of Name and the number of records in CustTemp[2].

What does this give?

The CustTemp[1] now has the value of the Name we insterted in CustTemp[2]. CustTemp[2] ignores the filter we used in CustTemp[1].

Ok Mark, great stuff but what can I do with this?

Microsoft uses this in at least two places in the standard Navision product.

The fist place is the UpdInvPostingBuffer() function in Codeunits 80 and 90. This temporary buffer variable has two dimensions which are used to combine a select distinct with a total of the values.

The second place is the Inventory Profile Offsetting Codeunit (99000854) in Navision Manufacturing. In this codeunit supply and demand is created in the InventoryProfile table.

 

Cheers,

/Marq