My post from my Android phone

I’ve had difficulties since day one with default Wordpress application for Android.
Today I discovered Post Bot, I sure hope this alternative works.
I’m about to find out soon enough ;)

EAN 8/13 Code 39/128 Barcode Creator

A couple of weeks ago I saw this post on Mibuso. This got my attention because this solution to make barcodes required no extra hassle with external components or fonts. A BMP containing the barcode is made using OutStreams, pretty neat stuff!

So I’ve started to use this piece of code to make barcodes of the type EAN8, EAN13, Code 128 & Code 39. In brief, all barcodes that I’ve already used in my (short) career.

A test with my mobile phone (Android :) ) and a handheld scanner quickly learned me that the barcodes were readable. At this point I decided to upload my code to Mibuso, and like this my first personal download on Mibuso is a fact!

Many thanks to Igor Pchelnikov for his initial post on Mibuso and the help he offered me to achieve this!

You can find the source code here: http://mibuso.com/dlinfo.asp?FileID=1192

All comments are off course more than welcome, this also counts for ratings. :)

BigText ADDTEXT difference 5 SP1 & 2K9 (SP1)

I wrote some code in NAV 2009 SP1 using a Bigtext variable and the ADDTEXT function. A quick test showed no problem at all.
Now I made a FOB of this same piece of code and imported it in a NAV 5 SP1 database. I was surprised to notice my code was no longer working…

After some debugging I found that the ADDTEXT function was behaving differently in NAV 5.

bxtBarcodeBinary.ADDTEXT(lrecTmpCode128.Encoding);

I’m fully aware of the fact that the ADDTEXT function expects that the field Encoding is of the datatype Text. But in fact it is of the datatype Code.

In NAV 2009 this works without any problem, one could speak of an implicit cast/conversion.

In NAV 5 SP1 however, the code above compiles and can be run but the result is an empty btxtBarcodeBinary.
So the solution for NAV 5 SP1 is to do conversion to Text (explicit cast/conversion).

bxtBarcodeBinary.ADDTEXT(FORMAT(lrecTmpCode128.Encoding));

Debugger and (Eset) firewall

Just recently I started having some troubles with NAV debugger. It would pop up when needed but the contents of it stayed crisp clean white… After closing it, it would pop up some more… and more… and more… You get the idea by now I guess.
It turned out my firewall was the culprit. The problem was solved by putting it in interactive mode. Launch the debugger and wait for the pop up from the firewall asking to make a new rule for the debugger process.
Problem solved!

Coding dependant form lookups

Sometimes it can come in handy to code a lookup on form level. Because the records shown in the lookup form are dependant on the value of another variable.

Practical example:
image
I have a form with an Item filter and a Variant filter. It would be intuitive if only the variants of the previously selected Item are shown. 

This can be achieved by putting the following piece of code behind the OnLookup trigger of the Variant Code field.

image

This also works for pages!

Coding date filters

Date filters on custom made forms are a common request. Apparently I’ve been coding it wrong the past years… until today of course! Maybe my biggest mistake was that I never bothered to look at how standard Nav handles this.

So, the best example is the Budget form (113), take a closer look at the Date Filter on the Filters tabpane of the form. The SourceExpr for this field is DateFilter, this is an ordinary text variable of length 30. So how come that this plain text field enables one to work with periods, workdate, weekdays,…
A closer look to the OnValidate trigger of the field shows the following:

image

So in codeunit 1 ApplicationManagement there’s a MakeDateFilter function that converts the text variable in a valid date filter. The last line of code fills the DateFilter field with the appropriate date(s) (range).

Adding new fields to the Item Tracking Lines form

While strawling on Mibuso I came across this post.
The thread is all about how to save custom data entered in the Item Tracking form. Not an easy job, as I already experienced myself. But then out of the blue someone posts this url:

http://www.nextequalzero.com/2007/12/how-to-add-new-fields-to-the-item-tracking-lines-form/

Which in fact is pure genius! So many thanks to matttrax for bringing this article to my attention and off course to the writer Ian Crocker!

This without any doubt one of the most useful post I’ve read… ever!

Create Reservation Entries for Item Journal Lines

This is actually a pretty straight forward thing… once you know it off course. There’s one codeunit who does all the ‘dirty’ work, 99000830 Create Reserv. Entry.
I’m using four functions:

  • SetDates(WarrantyDate : Date;ExpirationDate : Date)
  • SetApplyFromEntryNo(EntryNo : Integer)
  • CreateReservEntryFor(ForType : Option;ForSubtype : Integer;ForID : Code[20];ForBatchName : Code[10];ForProdOrderLine : Integer;ForRefNo : Integer;ForQtyPerUOM : Decimal;Quantity : Decimal;ForSerialNo : Code[20];ForLotNo : Code[20])
  • CreateEntry(ItemNo : Code[20];VariantCode : Code[10];LocationCode : Code[10];Description : Text[50];ExpectedReceiptDate : Date;ShipmentDate : Date;TransferredFromEntryNo : Integer;Status : Option)

Here’s a little piece of example code that will create a Reservation Entry for a Lot No.
image

TempBlob Table in Dynamics Nav 2009

Today I discovered a new table in Dynamics Nav 2009 (SP1).
Table 99008535 TempBlob, containing only 2 fields: a primary key and a Blob field.
Oh… and it’s empty and it should be at all time.
This table is handy when you need to use the Blob datatype but only for a short period.
With this table you can create a temporary record or initialize a record (without inserting it) just for the use of it’s Blob value.

Examples of use:

  • Use to hold image value to show an image in a picturebox at report runtime
    recTempBlob.Blob.IMPORT(c:\logo.bmp);
  • To hold XML file generated by an XMLport

Next on my wishlist is a similar table with for example 50 text fields. Just only to be used for temporary use only.

Binary compare files

To achieve this we can use the command FC in DOS. Please consult the help of FC for more info on comparison options (FC /?).

  • We’ll start with making the BAT file. Just copy the following text in a text file and rename it to COMPARE.CMD. Why do I use the CMD extension and not the BAT extension? More info here.

    @echo off
    FC /B %1 %2
    IF %ERRORLEVEL%==0 EXIT 0
    IF NOT %ERRORLEVEL%==0 EXIT 1

  • The next step is creating the compare function in Dynamics Nav.

    Name DataType Subtype Length
    lintWindowStyle integer    
    lblnWait Boolean    
    ltxtCommand Text   1024
    lautShell Automation ‘Windows Script Host Object Model’.WshShell  
    lintReturn Integer    


    fctCompare(ptxtFile1 : Text[200];ptxtFile2 : Text[200]) : Boolean

    lintWindowStyle := 0; // needs to be placed in variable
    lblnWait := TRUE;     // needs to be placed in variable
    ltxtCommand := ‘c:\compare.cmd “’+ ptxtFile1 +’” “’+ ptxtFile2+’”’;

    CLEAR(lautShell);
    CREATE(lautShell);

    lintReturn := lautShell.Run(ltxtCommand,lintWindowStyle,lblnWait);

    CASE lintReturn OF
      0: EXIT(TRUE);
      1: EXIT(FALSE);
    END;

  • Call the function: fctCompare(’c:\test1.txt’,'c:\test\test2.txt’);
    This will return TRUE if the files are identical and FALSE otherwise

Create a new blog and join in the fun!