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

Can I use multiline strings in Javascript?

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

  • Can I use multiline strings in Javascript?

    Can I use multiline strings in Javascript?

    I'm thinking that it'd be useful in something like long queries in javascript steps. I can close the string and concatenate, but a simple multiline string would be nice. Is it possible?
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.

  • #2
    Re:Can I use multiline strings in Javascript?

    Google found this trick that works in E4X compatible interpreters. I stuffed this into a filter just to test it.

    Code:
    var string = (<r><![CDATA[
    
         The text string goes here.  Since this is a XML CDATA section,
         stuff like <> work fine too, even if definitely invalid XML.
    
      ]]></r>«»).toString();
    
    logger.error(string);
    It works. So now your queries can look nice and neat in javascript steps. HOORAY!

    Post edited by: jbartels, at: 07/25/2008 08:14
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.

    Comment


    • #3
      Re:Can I use multiline strings in Javascript?

      I am trying to execute the following query and I am getting "Wrapped java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0" and "Wrapped java.sql.SQLException: Invalid cursor position" errors. The sql is correct but the concatenation might be invalid. Is there another option for using multiple lines in a sql clause within javascript for Mirth?


      Code:
      var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver', 'jdbc:jtds:«»sqlserver://127.0.0.1:2608/dtd_test', 'admin', 'admin');
      var string = (<r><![CDATA[
      var result = dbConn.executeCachedQuery(SELECT Ins.PolicyNumber as policynumber, 
      Ins.RelationToInsured as relationtoinsured, Ins.Record_Count as record_count, 
      Insco.InsCompany_Id as inscompany_id, Insco.InsCompany_Name as inscompany_name,
      Insadd.InsCompany_Line1 as inscompany_line1, Insadd.InsCompany_Line2 as inscompany_line2,
      Insadd.InsCompany_City as inscompany_city, Insadd.InsCompany_State as inscompany_state,
      Insadd.InsCompany_Zip as inscompany_zip, Insadd.InsCompany_Country as inscompany_country,
      Rec.Record_ID as record_id
      from Record Rec
      left outer join Insurance Ins on REC.Record_ID = Ins.Record_ID
      left outer join InsCompany Insco on REC.Record_ID = Insco.Record_ID
      left outer join InsCompany_Address Insadd on REC.Record_ID = Insadd.Record_ID 
      where Ins.Record_Count = Insco.Record_Count
      and Ins.Record_Count = Insadd.Record_Count);
      ]]></r>«»).toString();
      jbartels - edited to add code tags

      Post edited by: jbartels, at: 12/29/2008 14:16

      Comment


      • #4
        Re:Can I use multiline strings in Javascript?

        [email protected] wrote:
        I am trying to execute the following query and I am getting "Wrapped java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0" and "Wrapped java.sql.SQLException: Invalid cursor position" errors. The sql is correct but the concatenation might be invalid. Is there another option for using multiple lines in a sql clause within javascript for Mirth?
        Erk. I hope my edit to add code tags to your post didn't mess up the formatting, but it looks like you mixed it up a little bit. You only need the CDATA around the query, not around the script to actually run the query.

        Code:
        var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver', 'jdbc:jtds:«»sqlserver://127.0.0.1:2608/dtd_test', 'admin', 'admin');
        
        var string = (<r><![CDATA[
        SELECT Ins.PolicyNumber as policynumber, 
        Ins.RelationToInsured as relationtoinsured, Ins.Record_Count as record_count, 
        Insco.InsCompany_Id as inscompany_id, Insco.InsCompany_Name as inscompany_name,
        Insadd.InsCompany_Line1 as inscompany_line1, Insadd.InsCompany_Line2 as inscompany_line2,
        Insadd.InsCompany_City as inscompany_city, Insadd.InsCompany_State as inscompany_state,
        Insadd.InsCompany_Zip as inscompany_zip, Insadd.InsCompany_Country as inscompany_country,
        Rec.Record_ID as record_id
        from Record Rec
        left outer join Insurance Ins on REC.Record_ID = Ins.Record_ID
        left outer join InsCompany Insco on REC.Record_ID = Insco.Record_ID
        left outer join InsCompany_Address Insadd on REC.Record_ID = Insadd.Record_ID 
        where Ins.Record_Count = Insco.Record_Count
        and Ins.Record_Count = Insadd.Record_Count
        ]]></r>.toString();
        
        var result = dbConn.executeCachedQuery(string);
        Post edited by: jbartels, at: 12/29/2008 14:19
        Jon Bartels

        Zen is hiring!!!!
        http://consultzen.com/careers/
        Talented healthcare IT professionals wanted. Engineers to sales to management.
        Good benefits, great working environment, genuinely interesting work.

        Comment

        Working...
        X