Labels

Tuesday, June 21, 2011

Implementing interactive picture in NAV

Some time ago I was solving the task to print some interactive picture inside the NAV report. It means that user should draw some picture, import the picture in the document and then print it. The picture should be imported in NAV database to have an opportunity to re-print the document later.
Sub-task of producing Macromedia Flash presentation in which user can draw something was given to an outsource. This program was compiled like an ordinary exe-file, input parameter for it was a name of file to save the result (in bitmap format, of course).
When producing of this program was completed additional triggers were implemented:

InputVehiclePicture()


ServSetup.GET();
ServSetup.TESTFIELD( "Import Vehicle Picture Dir" );
ServSetup.TESTFIELD( "Import Vehicle Picture Command" );
IF COPYSTR( ServSetup."Import Vehicle Picture Dir", STRLEN( ServSetup."Import Vehicle Picture Dir" ), 1 ) <> '\' THEN
  ServSetup."Import Vehicle Picture Dir" := ServSetup."Import Vehicle Picture Dir" + '\';


FileL := ServSetup."Import Vehicle Picture Dir" + "No." + '.bmp';



IF SHELL( ServSetup."Import Vehicle Picture Command", FileL ) = 0 THEN;
IF EXISTS( FileL ) THEN BEGIN
  "Vehicle Picture".IMPORT( FileL );
  MODIFY();
  IF ERASE( FileL ) THEN;
END ELSE
  MESSAGE( Text002, FileL );

IF SHELL statement is used to wait for a program completion. After it NAV scans for the bitmap file and import it in BLOB field.
In the report object next code is used:

"Service Header".CALCFIELDS("Vehicle Picture");
IF "Service Header"."Vehicle Picture".HASVALUE=FALSE THEN
  "Service Header".InputVehiclePicture;
"Service Header".CALCFIELDS("Vehicle Picture");

  

No comments: