Scanning in Remote Desktop

When running Dynamics NAV as a Remote Application or in Remote Desktop you are missing connection to your locally connected scanner.  I have created a solution that uses a standalone application running on the client computer.  That application uses the TwainControlX from Ciansoft and connects to a Microsoft SQL database.  The database needs to be on a computer that both the client computer and the remote desktop computer have access to.

On that database server a database is created with only one table.  That table can be truncated every night in a maintenance job.  This is the table creation script.

CREATE TABLE [dbo].[ScanRequests](
	[ComputerName] [varchar](20) NOT NULL,
	[ClientName] [varchar](20) NOT NULL,
	[SelectedDeviceID] [varchar](250) NULL,
	[Image] [image] NULL,
	[RequestDateTime] [datetime] NULL,
	[FormatID] [varchar](50) NULL,
	[AnswerDateTime] [datetime] NULL,
	[Answered] [int] NOT NULL,
	[AnswerText] [varchar](250) NULL,
	[PageNo] [int] NULL

The program on the client then connects to the database and to the scanner.

A code in Dynamics NAV creates the request for a scan by inserting a entry into the ScanRequest table and the application on the client computer automatically scans the images and updates that scan request entry.  The updated entry then containes the image file that is imported into Dynamics NAV or attached as a link.

The following ZIP files are encrypted.  View the Product page for more information.

Twain Scanner (ISL)
NAV Myndlestur (TwainOCX) Source Code (ISL)


Icelandic Localization

In the localized version of Dynamics NAV 2009 R2 the report layout for Role Tailored Client is missing.  I have created the layout and applied a few fixes to the reports.

ID Name Caption
204 Sales – Quote Sala – Tilboð
205 Order Confirmation Pöntunarstaðfesting
206 Sales – Invoice Sala – Reikningur
207 Sales – Credit Memo Sala – Kreditreikningur
210 Blanket Sales Order Standandi sölupöntun
405 Order Pöntun
406 Purchase – Invoice Innkaup – Reikningur
407 Purchase – Credit Memo Innkaup – Kreditreikningur
10911 IRS Details Upplýs. vegna skattstofu
10912 Trial Balance – IRS Number Prófjöfnuður – Skattst.númer
10913 IRS notification Tilkynning skattayfirvalda
10940 VAT Balancing A VSK-afstemming A
10941 VAT Balancing Report VSK

The following ZIP file is encrypted.

NAV IS2009R2 Reports

File download with RTC

My earlier post on File Download used the responsestream property of WinHTTP. On my latest project I needed to use Windows Authentication on my website and found out that I needed to create the WinHTTP automation on client level to login with the current user. This also means that I cannot use built in streaming functions to download the file. Instead I used ADOStream function to download the file and in the example that follows I am saving the file to the temporary directory for the current user.
[code htmlscript=”false”]DownloadFile(URL : Text[1024]) FileName : Text[1024]

IF WinHTTP.status <> 200 THEN

FileName := WinHTTP.getResponseHeader(‘Content-Disposition’);
IF STRPOS(FileName,’filename=’) = 0 THEN
FileName := ”
FileName := COPYSTR(FileName,STRPOS(FileName,’filename=’) + 10);

IF ADOStream.State = 1 THEN

ADOStream.Type := 1; // adVarBinary


FileFolder := FileSystem.GetSpecialFolder(2);
FilePath := FileFolder.Path;
ADOStream.SaveToFile(FilePath + ‘\’ + FileName,2);
FileName := FilePath + ‘\’ + FileName;


Where my variables are

FileSystem – Automation – ‘Windows Script Host Object Model’.FileSystemObject
FileFolder – Automation – ‘Windows Script Host Object Model’.Folder
WinHTTP – Automation – ‘Microsoft XML, v6.0’.XMLHTTP
ADOStream – Automation – ‘Microsoft ActiveX Data Objects 2.8 Library’.Stream
FilePath – Text[1024]

Record Links and Attachments

The standard Record Links table in Dynamics NAV has the ability to store a URL and link it to any record in the Dynamics NAV database.  However, in order to fully use this each user must have access to the give URL.

As a part of the Purchase Invoice signing solution I built a process to select or scan a file, upload it to a SQL database and create a URL to that file in the Record Link table.  I create a  SQL link table that stores the file and a permission table that holds information on users permission by table id.

I used TwainControlX to scan and create files to import and link.  Then I add a “Link File” button to the Purchase Order.

When Link File is selected the following dialogue appears.

After selecting or scanning a file a new link is created and the file is uploaded to the SQL server.

The file is now available to all users that have the required permission through the following link.

The can be downloaded directly with the Open button or NAV can download and open the file with code.  I created a .ASP web page to download files from the Link database.