Microsoft Dynamics™ NAV – Show your files easily.

Home Microsoft Dynamics Nav TopicsMicrosoft Dynamics™ NAV – Show your files easily.
Microsoft Dynamics™ NAV – Show Item Picture

Microsoft Dynamics™ NAV – Show your files easily.

1 Comment

Microsoft Dynamics™ NAV – Show your files, documents, pictures, etc in Navision easily.

We show you a way to use Microsoft Dynamics™ NAV like content management, that allow to open any type of document, picture, pdf, etc. easily!

In this example, we create a new button on item card, that once executed will show an item picture. In this example we are using windows picture preview to show it.

We need to create a new control type “CommandButton” on form number 30 – Item Card and define the necessary variables used on trigger “OnPush” of new commandButton made. These variables could be defined on local or global way depending of form use.

1.- Variables Definition

  • Name: WshShell
  • Data Type: Automation
  • Subtype: ‘Windows Script Host Object Model’.WshShell
  • Description: // EBOXESFACTORY – Automation VBScript.
  • Name: intWindowStyle
  • Data Type: Integer
  • Description: // EBOXESFACTORY – Used to define the style of window on WshShell execution.
  • Name: bWaitOnReturn
  • Data Type: Boolean
  • Description: // EBOXESFACTORY – Used to define WshShell execution.
  • Name: intReturnValue
  • Data Type: Integer
  • Description: // EBOXESFACTORY – Used to retrive the return value of WshShell execution.
  • Name: ShellCommand
  • Data Type: Text (Length = 250)
  • Description: // EBOXESFACTORY – Used to inform the command to execute.
  • Name: FilePath
  • Data Type: Text (Length = 250)
  • Description: // EBOXESFACTORY – Used to inform path and name of file to show.
  • Name: AppCommand
  • Data Type: Text (Length = 250)
  • Description: // EBOXESFACTORY – Used to inform app command to use.

2.- Execution Code

Code to insert on trigger OnPush of new CommandButton created:

//>>> EBOXESFACTORY: Show Item Picture.
 
// 1.- Inform File Path and Name
FilePath := 'c:\bicycle.jpg';
 
// 2.- Inform App Command
AppCommand := 'c:\windows\system32\cmd.exe /c' //Windows CMD.exe in this example.
 
// 3.- Inform WshShell paramenters
ShellCommand := AppCommand+' '+FilePath;
bWaitOnReturn := FALSE; //FALSE = continue execution. TRUE = wait end of WshShell Run process.
intWindowStyle := 0; //0 = Hide App Window. 1 = Show App Window.
 
// 4.- Create Automation. By default FALSE, FALSE.
CREATE(WshShell,FALSE,FALSE);
 
// 5.- Run WshShell automation
intReturnValue := WshShell.Run(ShellCommand,intWindowStyle,bWaitOnReturn);
 
// 6.- Clear automation.
CLEAR(WshShell);
 
//<<< EBOXESFACTORY: Show Item Picture.

Once informed the previous steps, the final result will be like this:

eboxesfactory

When button “View Picture” is executed, the informed picture appears:

eboxesfactory

Leave a Reply

Your email address will not be published. Required fields are marked *