Using HYPERLINK to open external files
To open files externally, we use a hyperlink in most of the application or programming languages because it opens a file with the appropriate application. Let's see how we can use a hyperlink in NAV.
How to do it...
Create a new codeunit from Object Designer.
Then add the following global variables:
Name
Type
Selection
Integer
Write the following code in the
OnRun
trigger of the codeunit:Selection := STRMENU('Image,Website'); IF Selection = 1 THEN HYPERLINK('C:\Users\Public\Pictures\SamplePictures\Penguins.jpg') ELSE HYPERLINK('HTTP://www.mibuso.com');
It's time to save and close the codeunit.
How it works...
On execution of the codeunit, the system presents a simple selection menu where we need to choose between an image and a website. For both the options, we have provided the file location as a parameter to the HYPERLINK
function. HYPERLINK
visits the file location and loads that pointer using the default program on the current machine.
If we choose...