Follow me on Twitter

A technical eye on Microsoft Dynamics NAV

Using CuteFTPs COM interface in Microsoft Dynamics NAV

in Development by Ian Crocker


Photo credit: phatcontroller

CuteFTP is a popular FTP client application by GlobalSCAPE.

This articles demonstartes how to access and use CuteFTP’s transfer engine from within Microsoft Dynamics NAV to upload, rename and delete files on a remote ftp server. It’s slighlty more refined than the somewhat Heath Robinson approach required to use the in built windows ftp client described in an earlier article.

Click to continue →

How to apply field-level security in Microsoft Dynamics NAV

in Development by Ian Crocker


Photo credit: CarbonNYC

The use of field-level security in Dynamics NAV is something which is not yet possible as a standard front-end feature, but is possible to achieve by use of Roles, a small function and a line of code behind the field to be controlled.

  1. Make sure the ALL security role has Read permissions to Table Data 2000000003 Member Of
  2. Create a new Role to control access to the field(s). In this example I’m going to control access to the Unit Price field on the Item, so i’ve created a role called ITEM-UNITPRICE.
  3. Create a new Codeunit called FieldLevelSecurityManagement and a function calledCheckFieldPermission
  4. In the table where the field(s) to be controlled are located, create a global variable calledFieldLevelSecurityManagement which points to the FieldLevelSecurityManagement codeunit created above.

Now any user which hasn’t been granted specific permission to the Unit Price field will receive an error if they attempt to modify it.

fig 1.

						
									
						

Codeunit 416 Datetime Mgt. removed in Dynamics NAV 5.0

in Development by Ian Crocker


Photo credit: simpologist

Codeunit 416 Datetime Mgt. which contained functions to handle conversions to and from Date-Time type fields has been removed.

The inbuilt C/AL functions of CREATETIME, DT2TIME and DT2DATE should now be used instead.

These functions have been around for some time but with the NAV 5.0 release MS have streamlined the codebase by removing this codeunit and changing the references to it.

Any bespoke code which references this defunct codeunit will also need to be changed.

Click to continue →

How to perform an unattended FTP upload from Dynamics NAV

in Development by Ian Crocker


Photo credit: phatcontroller

There are a number of ways in which an FTP upload can be achieved in Dynamics NAV.

This article focuses on a neat way of utilising the in-built Windows FTP client.

It is achieved by generating a batch file from within NAV which is then launched and in turn writes an unattended script file which is then passed to the ftp command using the -s switch. All files are written on the fly in the temporary folder on the local machine and are gracefully cleaned up afterwards.

Click to continue →

How to use Windows Script Host Object Model instead of SHELL

in Development by Ian Crocker


Photo credit: Roee C.

Sometimes the SHELL command in Dynamics NAV doesn’t always work as we would like in every situation.

In such a case the Windows Script Host Object Model and it’s WshShell class may be an alternative method of running command line statements.

To build the function:

  1. Create a function called NAVShell which takes a Text parameter of 1024. This will be used to pass in the command line.
  2. Create a local variable called WshShell with a type of Automation and Subtype of ‘Windows Script Host Object Model’.WshShell
Enter the following code in the new function:
NAVShell(CommandLine : Text[1024])
CREATE(WshShell);
WshShell.Run(CommandLine);
CLEAR(WshShell);
We can now call the function as in the following example which launches notepad:
NAVShell(‘notepad.exe’);

What's cooking?

Photo credits

View Ian Crocker's profile on LinkedIn