Announcement

Collapse
No announcement yet.

[MC 3.0.1] Alerts messages "components"

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

  • [MC 3.0.1] Alerts messages "components"

    Hello,

    I use the new 3.0 alerting system to send simple alerts by email.

    In my transformer I just throw an exception with a message, and ine the alert template I just used the ${errorMessage} variable.

    The email body is as the following :

    CHANNEL: 100_CORA_INBOUND__________________
    CONNECTOR: sourceConnector
    SCRIPT SOURCE: TRANSFORMER
    SOURCE CODE:
    94: //GET ILP
    95: if(!result.next()){
    96: dbConn.close();
    97: logger.error("ERROR - Unable to find ILP for visit number " +$('NDA') + " in PASTEL");
    98: //alerts.sendAlert("ERROR");
    99: throw("ERROR - Unable to find ILP for visit number " + $('NDA') + " in PASTEL");
    100: }
    101: else {
    102: channelMap.put('ILP',result.getString(1));
    103: dbConn.close();
    LINE NUMBER: 99
    DETAILS: ERROR - Unable to find ILP for visit number 70063766 in PASTEL
    at 9dc9963d-18af-4719-a5bb-8e2c8cda0115:99 (doTransform)
    at 9dc9963d-18af-4719-a5bb-8e2c8cda0115:107 (doScript)
    at 9dc9963d-18af-4719-a5bb-8e2c8cda0115:109


    Is there a way to access to only some components (like "details", "channel", "code", ...) of the error message separately ?

    If not, how can I get only the message (in red) ?


    Thanks in advance for your help.

  • #2
    Put this in your global deploy script:

    Code:
    $g('LF','\n');
    Then you can use this in the e-mail subject field of the alert:

    Code:
    #set($start=$errorMessage.indexOf('DETAILS:')+8)#set($end=$errorMessage.indexOf($LF,$start))${errorMessage.substring($start,$end).trim()}
    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


    • #3
      god that's really tough to use velocity VTL for that.
      I tough there was some accessible getDetails() or getMessage() or getCode() methods in the errorMessage class API.

      Don't you think it could be a good idea for a future release ?

      for the time being, I wonder if it's not simpler to put the message in the global map and retrieve it using ${globalMapVariable}.

      many thanks

      Comment


      • #4
        hello,

        I tried to use this trick with MC 3.1.1, and it seems it does not "interpret" the VTL, neither in the email subject nor in the body.

        Do you have any idea ?

        thx

        Comment


        • #5
          I just tested it out in 3.1.1 and it works perfectly for me...
          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


          • #6
            Ok I think I get the problem.

            When I deploy a channel, I have a error regarding the global script.
            When I remove the $g('LF','\n'); line, I don't have this message anymore.

            So it doesn't work for me ;(

            Comment


            • #7
              Hello,

              finally I managed to make it work.
              The issue came from the way I built the errror message.

              If I put some string concatenations using variables in the throw statement, it doesn't work.
              If I build the error message in a variable, then put this string in the thow statement, it works.

              Example :

              Working -->

              Code:
              var erromsg = "<->" + sourceMap.get('originalFilename').toString() + " -- Le séjour ("+ $('VisitID')+ ") n'existe pas ou le nom du patient (" + $('PatientName') + ") ne correspond pas<->"
              throw(erromsg);
              Not working -->
              throw("<->" + sourceMap.get('originalFilename').toString() + " -- Le séjour ("+ $('VisitID')+ ") n'existe pas ou le nom du patient (" + $('PatientName') + ") ne correspond pas<->");


              and in the alert email body :

              #set ( $start=$errorMessage.indexOf("<->")+3 )
              #set ( $end=$errorMessage.indexOf("<->",$start) )
              #set ( $sbt=$errorMessage.substring($start,$end) ) $sbt


              Note that I used some special <-> markers to delimit my message, since the \n (LF) was not detected on my conf.

              Maybe its because I use the throw in the java way, not in the javascrit way.

              Comment

              Working...
              X