Delete a File using a Mirth JavaScript Transformer Channel.
So you have developed an awesome HL7 interface channel using Mirth and you are using a JavaScript Transformer to manipulate some files on the file system. You have managed to read the contents of the file and have processed the relevant data, Great News. However you wish to remove the original file as no one wants to have old pointless processed data files hanging around now do they ? So you have used FileUtil.ReadBytes() to actually open and read the data from the file so what would be the natural method to call to delete this file, FileUtil.Delete() ? NO, How Very Dare You ! This wont work , you will receive a java-script error not pass Go and NOT receive 200 Pounds! What you have to actually do is call straight to the Java io File class and run the file delete call that way. Something along the following lines : var file = Packages.java.io.File("\FILE NAME"«»); file["delete"](); But Why such a Foible ? Because the javascript.Delete() command gets lost between the translation of java-script to java and ’delete’ is a keyword in Rhino and E4X, thus you cant call File.delete() method within Mirth directly. So there you go , its that simple ! If you liked this article and found it use-full please share it below [...]

