Announcement

Collapse
No announcement yet.

Javascript support

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

  • Javascript support

    What level of javascript support do we have when writing javascript transforms. I'm trying to perform standard date conversion methods and my channel craps out because the .getYear, .getDate etc. doesn't exist.

    I tried using the the formDate method from the reference list and I get

    "Can't find method com.webreach.mirth.server.util.DateUtil.formatDate "

    Am I missing a library of functions??

  • #2
    Re:Javascript support

    Not sure about the specific error but for doing date conversion, the following link may help:
    Best practises - How do I ... ? - DateTime conversion

    Comment


    • #3
      Re:Javascript support

      I'm trying to do the exact opposite of that. I need to go from "04/12/1945" to "19450412000000"

      I tried this but get the error I mentioned previously, "Can't find method com.webreach.mirth.server.util.DateUtil.formatDate "

      Code:
      var dt = Date.parse(msg['dob'].toString());
      var dateString = DateUtil.formatDate('yyyyMMdd', dt);
      tmp['PID']['PID.7']['TS.1'] = dateString + '000000';

      Comment


      • #4
        Re:Javascript support

        Code:
        var datestring = DateUtil.convertDate("MM/dd/yyyy", "yyyyMMdd", msg['dob'].toString());
        This will convert from your inpattern (first argument) to your outpattern (second argument).
        Chris Lang

        Comment


        • #5
          Re:Javascript support

          Also -
          The reason this doesn't work is because Date.parse is a Javascript function and returns a Javascript object. DateUtil.formatDate expects a Java date as it's second parameter, hence you are getting the "can't find method..."
          Chris Lang

          Comment

          Working...
          X