Announcement

Collapse
No announcement yet.

Conditional execution of channel

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

  • Conditional execution of channel

    Hi,

    I've made a channel with Database reader in source and File Writer in destination with 10 minutes of polling frequency.

    I want this channel running only between 10:00 and 12:00 so I've wrote some javascript in the source area like this:

    Code:
    var vSQL = " select  rownum as nomfit, ";
    vSQL = vSQL + "        visi_centre_codi_centre as centre, ";
    vSQL = vSQL + "...";
    
    var result=""
    var Hora=DateUtil.getCurrentDate('HH');
    
    if (Hora>="10" && Hora <="12"«»)
    	{ 
    	var dbConn = DatabaseConnectionFactory.createDatabaseConnection('oracle.jdbc.OracleDriver','jdbc:oracle:thin:@10.80.217.40:1521:orac','RADHTR','xxxxxx');
    	result = dbConn.executeCachedQuery(vSQL);
    	dbConn.close();
    	}
    
    // YOUR CODE GOES HERE 
    
    // You may access this result with $('column_name')
    return result;
    this code runs correctly but I've got the following message when the channel works before 10:00 and after 12:00 because result variable hasn't a proper value.
    "[2008-09-23 06:26:53,938] ERROR (com.webreach.mirth.connectors.jdbc.JdbcMessageRec eiver:240): Got a result of:"

    What I must return at the end of code to achieve the channel does nothing?

    thanks

    carles massallé

    Post edited by: carles, at: 09/23/2008 02:18

    Post edited by: carles, at: 09/23/2008 02:53

  • #2
    Re:Conditional execution of channel

    Try to use this code.

    Code:
    var vSQL = " select  rownum as nomfit, ";
    vSQL = vSQL + "        visi_centre_codi_centre as centre, ";
    vSQL = vSQL + "...";
    
    var result=""
    var Hora=DateUtil.getCurrentDate('HH');
    
    if (Hora>="10" && Hora <="12"«»)
        { 
        var dbConn = DatabaseConnectionFactory.createDatabaseConnection('oracle.jdbc.OracleDriver','jdbc:oracle:thin:@10.80.217.40:1521:orac','RADHTR','xxxxxx');
        result = dbConn.executeCachedQuery(vSQL);
        dbConn.close();
        // YOUR CODE GOES HERE 
        // You may access this result with $('column_name')
        return result;
        }
    else
        {
        return false;
        }
    Post edited by: Nonoy, at: 09/23/2008 23:55

    Post edited by: Nonoy, at: 09/23/2008 23:57

    Comment


    • #3
      Re:Conditional execution of channel

      Thanks a lot, Nonoy

      This code works very well.

      It was really simple at all.

      carles

      Comment


      • #4
        Re:Conditional execution of channel

        This additional information might be usefull to others:

        Code:
        return false;
        shows an ERROR (com.webreach.mirth.connectors.jdbc.JdbcMessageRec eiver:240): Got a result of: false

        Code:
        return new Packages.java.util.ArrayList();
        will return an empty result set and the server log will stay clean.
        found this in another thread

        ps. Thanks for this thread it was very usefull to us.

        Post edited by: elankreijer, at: 10/15/2008 03:58

        Comment


        • #5
          excellent, thanks a lot.

          Comment


          • #6
            Note that in the latest versions of Mirth Connect you can easily set hour ranges for polling connectors:

            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment

            Working...
            X