Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Javascript replace problem.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript replace problem.

    I don't seem to be able to use the javascript replace() function.

    I try to remove spaces from the start of a string like
    Code:
    Value=Value.replace(/^\s/g, '');
    And I get a big dirty fail

    Code:
    ERROR-300: Transformer error
    ERROR MESSAGE:	Error evaluating transformer
    java.lang.IllegalArgumentException: Name is not valid
    	at org.apache.xmlbeans.impl.store.Cursor.validateLocalName(Cursor.java:125)
    	at org.apache.xmlbeans.impl.store.Cursor._insertElementWithText(Cursor.java:1715)
    	at org.apache.xmlbeans.impl.store.Cursor._beginElement(Cursor.java:1689)
    	at org.apache.xmlbeans.impl.store.Cursor.beginElement(Cursor.java:4127)
    	at org.mozilla.javascript.xmlimpl.XML.createTextElement(XML.java:217)
    	at org.mozilla.javascript.xmlimpl.XML.makeXmlFromString(XML.java:1044)
    	at org.mozilla.javascript.xmlimpl.XML.putXMLProperty(XML.java:1309)
    	at org.mozilla.javascript.xmlimpl.XML.replace(XML.java:2726)
    	at org.mozilla.javascript.xmlimpl.XMLList.replace(XMLList.java:1316)
    	at org.mozilla.javascript.xmlimpl.XMLObjectImpl.execIdCall(XMLObjectImpl.java:655)
    	at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:124)
    	at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:74)
    	at org.mozilla.javascript.gen.c361._c13(a245e6d5-a56e-4cb5-bc25-027d205b261f:77)
    	at org.mozilla.javascript.gen.c361.call(a245e6d5-a56e-4cb5-bc25-027d205b261f)
    	at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:106)
    	at org.mozilla.javascript.gen.c361._c0(a245e6d5-a56e-4cb5-bc25-027d205b261f:108)
    	at org.mozilla.javascript.gen.c361.call(a245e6d5-a56e-4cb5-bc25-027d205b261f)
    	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
    	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
    	at org.mozilla.javascript.gen.c361.call(a245e6d5-a56e-4cb5-bc25-027d205b261f)
    	at org.mozilla.javascript.gen.c361.exec(a245e6d5-a56e-4cb5-bc25-027d205b261f)
    	at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:393)
    	at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:346)
    	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 com.webreach.mirth.server.controllers.MessageObjectController.getMessageObjectFromEvent(MessageObjectController.java:507)
    	at com.webreach.mirth.connectors.email.SmtpMessageDispatcher.doDispatch(SmtpMessageDispatcher.java:90)
    	at com.webreach.mirth.connectors.email.SmtpMessageDispatcher.doSend(SmtpMessageDispatcher.java:145)
    	at org.mule.providers.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:166)
    	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:191)
    	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:130)
    	at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:85)
    	at org.mule.routing.outbound.FilteringMulticastingRouter.route(FilteringMulticastingRouter.java:89)
    	at org.mule.routing.outbound.OutboundMessageRouter$1.doInTransaction(OutboundMessageRouter.java:78)
    	at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:48)
    	at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:82)
    	at org.mule.impl.model.DefaultMuleProxy.onCall(DefaultMuleProxy.java:247)
    	at org.mule.impl.model.seda.SedaComponent.doSend(SedaComponent.java:209)
    	at org.mule.impl.model.AbstractComponent.sendEvent(AbstractComponent.java:277)
    	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:201)
    	at org.mule.routing.inbound.InboundMessageRouter.send(InboundMessageRouter.java:161)
    	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:128)
    	at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:493)
    	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:272)
    	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:231)
    	at com.webreach.mirth.connectors.file.FileMessageReceiver.processFile(FileMessageReceiver.java:236)
    	at com.webreach.mirth.connectors.file.FileMessageReceiver.poll(FileMessageReceiver.java:138)
    	at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:118)
    	at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
    	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    	at java.lang.Thread.run(Unknown Source)
    Can anyone shed some light - of give me another way to trim strings?

  • #2
    Re:Javascript replace problem.

    It looks like the "Value" variable isn't properly declared. Perhaps are you getting it from a Mapping transformer step ?

    Can you post the whole code o channel export ?

    Comment


    • #3
      Solution?

      Did anyone find a solution to this, I'm having the exact same problem when I try to do it too:

      function Trim(sValue)
      {
      return sValue.replace(/^\s*([\S\s]*?)\s*$/, '$1');
      }

      Comment


      • #4
        I think I figured it out

        I beleive in some cases you need to call .toString() on your value before calling the replace method on it.

        Comment


        • #5
          jerchap is correct. Call the .toString() when you are initially setting your variable and that seems to fix the issue.

          Comment

          Working...
          X