Search code examples
javascriptmirth

Mirth connect javascript reader


I am using mirth connect 3.0.3 on windows.my requirement is I have a text file in D drive with some name and id as the text I need to pick that file using mirth javascript reader and insert into the database can u please help me to pick the file using javascript reader.

I tried it by using java code and converting that into to .jar file and placed it in the custom-lib folder in mirth connect and importing that in a script but I want to do it without .jar file

I am getting stuck in importing the packages can you help me to pick the file using javascript reader.


Solution

  • You can take two aproaches:

    1. Use a File Reader source insted of JavaScript Reader source, then modify the transformer adding a new step in which insert your file's content into your database.

    2. Use the FileUtil.read method to read file content inside your Javascript Reader source:

        var fileData = FileUtil.read('D:\my_awesome_folder\data.txt');
    
        //Do something with fileData