BLOB's in XMLPORTS

I would like to know if anyone have tried to export/import BLOB fields in XMLPORTS?

If yes, and it is possible, then how?

Nobody??

You’ve got me curious Erik, let’s develop it. So are we doing this for text or binary data into the BLOB field? Is the data going into the BLOB actually IN the xml file or does a tag point to the data/file in a external location (path filename, url)?

Actually I want to take a BLOB field from one Navision table and export them and import the BLOB into another table in another Navison database. To be more specific - I want to export the Object BLOB and import it into a table so that I can keep a full copy of the existing object in another database. Weather that part will work or not I still don’t know. But it was more the BLOB issue I got stuck on.

After messing with it on and off today, I worked out a solution…

The code is pretty straight-forward, but I’ll comment on it anyway…

The codeunit allows testing the export and import functionality of the XMLPort. I’m using the standard Item table and the Picture field. Using the import and export triggers on the XMLPort I use a function to export or import the BLOB field. In this case the Picture field with a 48kb bitmap. Inbetween the export and import of the xml file I change the item number in order to bring it in as a new item.

OBJECT Codeunit 50001 test
{
OBJECT-PROPERTIES
{
Date=11/13/06;
Time=[ 4:10:11 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
Import := 1 = STRMENU(‘Import,Export’,1);
IF NOT Import THEN BEGIN
ExportFile.CREATE(‘c:\ItemXMLExport.xml’);
ExportFile.WRITEMODE(TRUE);
ExportFile.CREATEOUTSTREAM(FileOutStream);
Item.SETRANGE(“No.”, ‘7084’);
XMLPORT.EXPORT(XMLPORT::“Item XML Export-Import”, FileOutStream, Item);
ExportFile.CLOSE;
END ELSE BEGIN
ImportFile.OPEN(‘c:\ItemXMLExport.xml’);
ImportFile.CREATEINSTREAM(FileInStream);
XMLPORT.IMPORT(XMLPORT::“Item XML Export-Import”, FileInStream);
ImportFile.CLOSE;
END;
END;

}
CODE
{
VAR
ExportFile@1000000001 : File;
FileOutStream@1000000000 : OutStream;
FileInStream@1000000004 : InStream;
Item@1000000002 : Record 27;
ImportFile@1000000003 : File;
Import@1000000005 : Boolean;

BEGIN
END.
}
}

OBJECT XMLport 50000 Item XML Export-Import
{
OBJECT-PROPERTIES
{
Date=11/13/06;
Time=[ 4:08:51 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
}
ELEMENTS
{
{ [{694F51B7-F1F7-48BB-AF09-6B6B6D897EE0}]; ;ItemData ;Element ;Text }

{ [{2A5D451C-53E5-49CA-B589-4068DD77FF45}];1 ;Item ;Element ;Table ;
VariableName=Item;
SourceTable=Table27 }

{ [{4AF56BF0-D8CE-47DD-8648-3D4712AA2EFE}];2 ;No ;Element ;Field ;
DataType=Code;
SourceField=Item::No. }

{ [{C3D639AE-DCF4-448A-8FDB-D9E6C1F44A7D}];2 ;Description ;Element ;Field ;
DataType=Text;
SourceField=Item::Description }

{ [{B26960A2-9047-4666-8058-30DC364C1FF6}];2 ;Picture ;Element ;Text ;
VariableName=PicturePath;
Import::OnAfterAssignVariable=BEGIN
ImportPicture;
END;

Export::OnBeforePassVariable=BEGIN
ExportPicture;
END;
}

}
EVENTS
{
}
CODE
{

PROCEDURE ExportPicture@1000000000();
VAR
PictureExportFile@1000000001 : File;
PictureOutStream@1000000000 : OutStream;
BEGIN
Item.CALCFIELDS(Picture);
IF Item.Picture.HASVALUE THEN BEGIN
PicturePath := ‘c:\temp\itempictures’ + Item.“No.”;
Item.Picture.EXPORT(PicturePath);
END;
END;

PROCEDURE ImportPicture@1000000001();
BEGIN
IF EXISTS(PicturePath) THEN
Item.Picture.IMPORT(PicturePath);
END;

BEGIN
END.
}
}

Erik, take a look @ standart XMLPort 99008500, it is exporting item picture as blob.

Thank you - great!