Testing XML Ports

I’ve just started to experiment with XML ports and have created a relatively simple port to extract records from the Sales Invoice table. I seem to remember reading somewhere that the way to test an XMLPort is create a codeunit to execute it, but haven’t seen this implemented anywhere yet. Has anybody got any examples of this, or alternatively a better suggestion. Many thanks

Hi Gary, Try the following code: OBJECT Codeunit 50000 ExportXML { OBJECT-PROPERTIES { Date=18-01-05; Time=12:00:00; Version List=; } PROPERTIES { OnRun=BEGIN OutputFile.TEXTMODE(TRUE); OutputFile.WRITEMODE(TRUE); OutputFile.QUERYREPLACE(TRUE); OutputFile.CREATE(‘c:\myXML.xml’); OutputFile.CREATEOUTSTREAM(OutputStream); XMLPORT.EXPORT(50000,OutputStream); OutputFile.CLOSE; END; } CODE { VAR OutputFile@1000000 : File; OutputStream@1000001 : OutStream; BEGIN END. } } Remember to replace 50000 with the ID of your XMLPort. :slight_smile: Good luck!

Perfect. Thank you very much