com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 4816: } 4817: };var release_tag = 50;function doScript() { 4818: // This script executes once when the mule engine is started 4819: // You only have access to the globalMap here to persist data 4820: 4821: message = message.replace(/:/g, "|") 4822: message = message.replace (/;/g, "^"); 4823: return message; 4824: } LINE NUMBER: 4820 DETAILS: ReferenceError: "message" is not defined.

Mirth Project | Igor Ges | 6 years ago
  1. 0

    After importing Mirth 1.8.2 channels into a new instance of Mirth 2.0.0 we keep getting the same error when starting Mirth. The error seems to happen in the channel preprocessor. {noformat} NFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: Mirth Connect 2.0.0.5127 (October 28, 2010) server s arted: Thu Nov 04 15:22:05 CST 2010 INFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: This product was developed by Mirth Corporation (htt orp.com) and its contributors (c)2005-2010. INFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: Running Java HotSpot(TM) 64-Bit Server VM 1.6.0_20 o at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) ERROR 2010-11-04 15:22:04,250 [Thread-2] com.mirth.connect.server.util.JavaScriptUtil: Error executing f2439943-2775-416b-8df c-1fd7d920f9eb_Deploy script from channel: f2439943-2775-416b-8dfc-1fd7d920f9eb com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 4816: } 4817: };var release_tag = 50;function doScript() { 4818: // This script executes once when the mule engine is started 4819: // You only have access to the globalMap here to persist data 4820: 4821: message = message.replace(/:/g, "|") 4822: message = message.replace (/;/g, "^"); 4823: return message; 4824: } LINE NUMBER: 4820 DETAILS: ReferenceError: "message" is not defined. at com.mirth.connect.server.util.JavaScriptUtil.executeScript(JavaScriptUtil.java:251) at com.mirth.connect.server.util.JavaScriptUtil.executeChannelDeployOrShutdownScript(JavaScriptUtil.java:180) at com.mirth.connect.server.controllers.DefaultScriptController.executeChannelDeployScript(DefaultScriptController.ja va:197) at com.mirth.connect.server.controllers.MuleEngineController.deployChannels(MuleEngineController.java:199) at com.mirth.connect.server.controllers.MuleEngineController.redeployAllChannels(MuleEngineController.java:281) at com.mirth.connect.server.controllers.MuleEngineController.startEngine(MuleEngineController.java:144) at com.mirth.connect.server.Mirth.startEngine(Mirth.java:205) at com.mirth.connect.server.Mirth.startup(Mirth.java:176) at com.mirth.connect.server.Mirth.run(Mirth.java:126) INFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: Mirth Connect 2.0.0.5127 (October 28, 2010) server s uccessfully started: Thu Nov 04 15:22:05 CST 2010 INFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: This product was developed by Mirth Corporation (htt p://www.mirthcorp.com) and its contributors (c)2005-2010. INFO 2010-11-04 15:22:05,231 [Thread-2] com.mirth.connect.server.Mirth: Running Java HotSpot(TM) 64-Bit Server VM 1.6.0_20 o n Linux (2.6.18-xen, amd64) with charset UTF-8. {noformat}

    Mirth Project | 6 years ago | Igor Ges
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 4816: } 4817: };var release_tag = 50;function doScript() { 4818: // This script executes once when the mule engine is started 4819: // You only have access to the globalMap here to persist data 4820: 4821: message = message.replace(/:/g, "|") 4822: message = message.replace (/;/g, "^"); 4823: return message; 4824: } LINE NUMBER: 4820 DETAILS: ReferenceError: "message" is not defined.
  2. 0

    Try the following in a 2.x preprocessor: \\ \\ {code}logger.info(typeof messageObject);{code} It outputs "undefined", as expected. However in 3.x it will now throw an error: \\ \\ {code}[2014-03-03 09:09:23,887] ERROR (com.mirth.connect.server.util.javascript.JavaScriptUtil:464): Error executing Preprocessor script from channel: 880e07cc-0729-42c5-a146-29c4b3253f9c com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 187: }188: }189: function doScript() {190: // Modify the message variable below to pre process data191: 192: logger.info(typeof messageObject);193: 194: return message; 195: }LINE NUMBER: 192DETAILS: Invalid JavaScript value of type com.mirth.connect.server.userutil.MessageObject at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:192 (doScript) at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:196 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:489) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:183) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724){code} \\ \\ In addition, try this code: \\ \\ {code}if (messageObject) logger.info('messageObject exists');{code} In 2.x, it throws an error: \\ \\ {code}[2014-03-03 09:14:51,142] ERROR (com.mirth.connect.server.util.JavaScriptUtil:264): Error executing Preprocessor script from channel: faf8272e-b76d-4cd6-984f-55b23cdb21de com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9 at com.mirth.connect.server.util.JavaScriptUtil.executeScript(JavaScriptUtil.java:289) at com.mirth.connect.server.util.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:166) at com.mirth.connect.server.mule.transformers.JavaScriptPreprocessor.transform(JavaScriptPreprocessor.java:40) at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48) at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197) at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251) at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61) at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79) at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225) at com.mirth.connect.connectors.vm.VMMessageReceiver.getMessages(VMMessageReceiver.java:222) at org.mule.providers.TransactedPollingMessageReceiver.poll(TransactedPollingMessageReceiver.java:108) at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97) at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:724){code} However in 3.x you now get warnings from Rhino: \\ \\ {code}[2014-03-03 09:14:40,233] ERROR (Server:146): RHINO USAGE WARNING: Missed Context.javaToJS() conversion: [2014-03-03 09:14:40,233] ERROR (Server:146): Rhino runtime detected object message 9-0 (RECEIVED) of class com.mirth.connect.server.userutil.MessageObject where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.{code}

    Mirth Project | 3 years ago | Nick Rupley
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9
  3. 0

    Try the following in a 2.x preprocessor: \\ \\ {code}logger.info(typeof messageObject);{code} It outputs "undefined", as expected. However in 3.x it will now throw an error: \\ \\ {code}[2014-03-03 09:09:23,887] ERROR (com.mirth.connect.server.util.javascript.JavaScriptUtil:464): Error executing Preprocessor script from channel: 880e07cc-0729-42c5-a146-29c4b3253f9c com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 187: }188: }189: function doScript() {190: // Modify the message variable below to pre process data191: 192: logger.info(typeof messageObject);193: 194: return message; 195: }LINE NUMBER: 192DETAILS: Invalid JavaScript value of type com.mirth.connect.server.userutil.MessageObject at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:192 (doScript) at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:196 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:489) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:183) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724){code} \\ \\ In addition, try this code: \\ \\ {code}if (messageObject) logger.info('messageObject exists');{code} In 2.x, it throws an error: \\ \\ {code}[2014-03-03 09:14:51,142] ERROR (com.mirth.connect.server.util.JavaScriptUtil:264): Error executing Preprocessor script from channel: faf8272e-b76d-4cd6-984f-55b23cdb21de com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9 at com.mirth.connect.server.util.JavaScriptUtil.executeScript(JavaScriptUtil.java:289) at com.mirth.connect.server.util.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:166) at com.mirth.connect.server.mule.transformers.JavaScriptPreprocessor.transform(JavaScriptPreprocessor.java:40) at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48) at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197) at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251) at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61) at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79) at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225) at com.mirth.connect.connectors.vm.VMMessageReceiver.getMessages(VMMessageReceiver.java:222) at org.mule.providers.TransactedPollingMessageReceiver.poll(TransactedPollingMessageReceiver.java:108) at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97) at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:724){code} However in 3.x you now get warnings from Rhino: \\ \\ {code}[2014-03-03 09:14:40,233] ERROR (Server:146): RHINO USAGE WARNING: Missed Context.javaToJS() conversion: [2014-03-03 09:14:40,233] ERROR (Server:146): Rhino runtime detected object message 9-0 (RECEIVED) of class com.mirth.connect.server.userutil.MessageObject where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.{code}

    Mirth Project | 3 years ago | Nick Rupley
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Try the following in a 2.x preprocessor: \\ \\ {code}logger.info(typeof messageObject);{code} It outputs "undefined", as expected. However in 3.x it will now throw an error: \\ \\ {code}[2014-03-03 09:09:23,887] ERROR (com.mirth.connect.server.util.javascript.JavaScriptUtil:464): Error executing Preprocessor script from channel: 880e07cc-0729-42c5-a146-29c4b3253f9c com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 187: }188: }189: function doScript() {190: // Modify the message variable below to pre process data191: 192: logger.info(typeof messageObject);193: 194: return message; 195: }LINE NUMBER: 192DETAILS: Invalid JavaScript value of type com.mirth.connect.server.userutil.MessageObject at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:192 (doScript) at 880e07cc-0729-42c5-a146-29c4b3253f9c_Preprocessor:196 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:489) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:183) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724){code} \\ \\ In addition, try this code: \\ \\ {code}if (messageObject) logger.info('messageObject exists');{code} In 2.x, it throws an error: \\ \\ {code}[2014-03-03 09:14:51,142] ERROR (com.mirth.connect.server.util.JavaScriptUtil:264): Error executing Preprocessor script from channel: faf8272e-b76d-4cd6-984f-55b23cdb21de com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9 at com.mirth.connect.server.util.JavaScriptUtil.executeScript(JavaScriptUtil.java:289) at com.mirth.connect.server.util.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:166) at com.mirth.connect.server.mule.transformers.JavaScriptPreprocessor.transform(JavaScriptPreprocessor.java:40) at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48) at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197) at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251) at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61) at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79) at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266) at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225) at com.mirth.connect.connectors.vm.VMMessageReceiver.getMessages(VMMessageReceiver.java:222) at org.mule.providers.TransactedPollingMessageReceiver.poll(TransactedPollingMessageReceiver.java:108) at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97) at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:724){code} However in 3.x you now get warnings from Rhino: \\ \\ {code}[2014-03-03 09:14:40,233] ERROR (Server:146): RHINO USAGE WARNING: Missed Context.javaToJS() conversion: [2014-03-03 09:14:40,233] ERROR (Server:146): Rhino runtime detected object message 9-0 (RECEIVED) of class com.mirth.connect.server.userutil.MessageObject where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.{code}

    Mirth Project | 3 years ago | Nick Rupley
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 1: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (globalChannelMap.containsKey(string)) { return globalChannelMap.get(string);} else if (globalMap.containsKey(string)) { return globalMap.get(string);} else { return ''; }}function addAttachment(data, type) {var attachment = Packages.com.mirth.connect.server.controllers.MessageObjectController.getInstance().createAttachment(data, type);muleContext.getProperties().get('attachments').add(attachment); 2: return attachment; }3: function $gc(key, value){if (arguments.length == 1){return globalChannelMap.get(key); }else if (arguments.length == 2){globalChannelMap.put(key, value); }}function $g(key, value){if (arguments.length == 1){return globalMap.get(key); }else if (arguments.length == 2){globalMap.put(key, value); }}function doScript() {4: // Modify the message variable below to pre process data5: if (messageObject)6: logger.info('messageObject exists');7: return message; 8: }LINE NUMBER: 5DETAILS: ReferenceError: "messageObject" is not defined. at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:5 (doScript) at faf8272e-b76d-4cd6-984f-55b23cdb21de_Preprocessor:9
  6. 0

    I use the following code in my PreProcessor under a Mirth Connect Channel: // initialize a first_iteration flag. // we don't want to add a carriage return // before the MSH segment var first_iteration = true; // initialize the new message as an empty string var new_message = ''; // loop over each line in the message // by splitting on the hl7 standard carriage return for each (var line in message.split(/\r/)) { // if it is a valid hl7 segment, we'll // append the new line to the new message logger.error(line); if(line.match(/^[a-zA-Z0-9]{3}\|/)) { // see the first comment if( ! first_iteration){ new_message += '\r'; } new_message += line; } else { // if it isn't a valid hl7 segment, // we'll append it to the end of the // previous segment instead new_message += ' ' + line; } // it will never be the first_iteration again first_iteration = false; } logger.error(new_message); new_message = new_message.replace(/[']{1}/gi,"''"); new_message = new_message.replace(/[\x08]{1}/gi,""); //Look for the Backspace character //send the fixed message to the channel message = new_message; return message; I GET THE FOLLOWING ERROR MESSAGE: Preprocessor Script error ERROR MESSAGE: Error running preprocessor scripts com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:490) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:184) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

    Mirth Project | 3 years ago | Ivan Olmos
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mirth.connect.server.MirthJavascriptTransformerException

      SOURCE CODE: 4816: } 4817: };var release_tag = 50;function doScript() { 4818: // This script executes once when the mule engine is started 4819: // You only have access to the globalMap here to persist data 4820: 4821: message = message.replace(/:/g, "|") 4822: message = message.replace (/;/g, "^"); 4823: return message; 4824: } LINE NUMBER: 4820 DETAILS: ReferenceError: "message" is not defined.

      at com.mirth.connect.server.util.JavaScriptUtil.executeScript()
    2. com.mirth.connect
      Mirth.run
      1. com.mirth.connect.server.util.JavaScriptUtil.executeScript(JavaScriptUtil.java:251)
      2. com.mirth.connect.server.util.JavaScriptUtil.executeChannelDeployOrShutdownScript(JavaScriptUtil.java:180)
      3. com.mirth.connect.server.controllers.DefaultScriptController.executeChannelDeployScript(DefaultScriptController.java:197)
      4. com.mirth.connect.server.controllers.MuleEngineController.deployChannels(MuleEngineController.java:199)
      5. com.mirth.connect.server.controllers.MuleEngineController.redeployAllChannels(MuleEngineController.java:281)
      6. com.mirth.connect.server.controllers.MuleEngineController.startEngine(MuleEngineController.java:144)
      7. com.mirth.connect.server.Mirth.startEngine(Mirth.java:205)
      8. com.mirth.connect.server.Mirth.startup(Mirth.java:176)
      9. com.mirth.connect.server.Mirth.run(Mirth.java:126)
      9 frames