Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   [MC 3.0.1] Alerts messages "components" (http://www.mirthcorp.com/community/forums/showthread.php?t=10363)

lionelroux 04-15-2014 02:19 AM

[MC 3.0.1] Alerts messages "components"

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
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();
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.

narupley 04-15-2014 09:34 AM

Put this in your global deploy script:


Then you can use this in the e-mail subject field of the alert:



lionelroux 04-16-2014 06:08 AM

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

lionelroux 01-19-2015 07:35 AM


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 ?


narupley 01-19-2015 07:40 AM

I just tested it out in 3.1.1 and it works perfectly for me...

lionelroux 01-20-2015 08:37 AM

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 ;(

lionelroux 01-21-2015 01:46 AM


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 -->


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

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.

All times are GMT -8. The time now is 08:25 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation