|
#1
|
|||
|
|||
|
Hi All,
I am trying to write a simple java script to get the encoded message and writ it to a file. This script will be in the postprocessor. But it doesn't work ![]() var log1file="D:\TEST\log1.txt"; var ReportBody=(messageObject.getEncodedData()); FileUtil.write(log1file, true, "ReportBody"); Any help much appreciated. Thank you. |
|
#2
|
|||
|
|||
|
Quote:
Code:
org.apache.commons.io.FileUtils.write(new java.io.File('D:/TEST/log1.txt'),true,messageObject.getEncodedData());
Code:
org.apache.commons.io.FileUtils.write(new java.io.File('D:/TEST/log1.txt'),messageObject.getEncodedData(),true);
Last edited by narupley; 03-22-2012 at 06:32 AM. |
|
#3
|
|||
|
|||
|
Thank you for the prompt reply.
It's still not working: sorry.. dont' have much knowledge in scripting. [2012-03-22 13:03:48,386] ERROR (com.mirth.connect.server.util.JavaScriptUtil:264) : Error executing Postprocessor script from channel: f3c28251-0a18-4bcd-b2cf-6430387f3d9d com.mirth.connect.server.MirthJavascriptTransforme rException: SOURCE CODE: 10: 11: //var log1file='D:/log1.txt';12: //var ReportBody=(messageObject.getEncodedData());13: //FileUtil.write(log1file, true, "ReportBody");14: 15: org.apache.commons.io.FileUtils.write(new java.io.File('D:/TEST/log1.txt'),true,messageObject.getEncodedData());16 : 17: //FileUtil.write('D:\TEST\log.txt',true,getEncodedDa ta());18: 19: // Create an instance of the channelStatisticsController objectLINE NUMBER: 15DETAILS: Can't find method org.apache.commons.io.FileUtils.write(java.io.File ,boolean,java.lang.String). |
|
#4
|
|||
|
|||
|
It's OK. It worked!!! Thank you so much. :-)
|
|
#5
|
|||
|
|||
|
Yeah sorry, I got the parameters mixed up: FileUtils.write
|
|
#6
|
|||
|
|||
|
I just realised that it's sending the raw messages not the encoded message, where the script clearing saying encoded.
any ideas please? |
|
#7
|
|||
|
|||
|
That's because you're doing that code in your postprocessor, where you don't natively have access to the message objects of your destinations. The easiest way around that is to place whatever you need in the channel map, and then using it in the postprocessor.
|
|
#8
|
|||
|
|||
|
Hi
I am still struggling with this.. I have created couple of mappers and JavaScript, all in the destination transformer. Variable: log1file Mapping: 'D:/TEST/log1.txt' Variable: messagetext Mapping: messageObject.getEncodedData() Then the JS : FileUtil.write($('log1file'), true, $('messagetext')); This way I get an empty file created!!! I am not sure where I am going wrong here. Thanks. |
|
#9
|
|||
|
|||
|
Quote:
Code:
org.apache.commons.io.FileUtils.write(new java.io.File($('log1file').toString()),$('messagetext').toString(),true);
|
|
#10
|
|||
|
|||
|
Yes the variables are in channel map.
I copied your code and tried again, getting the same result. Empty file. :-( |
![]() |
| Thread Tools | |
| Display Modes | |
|
|