web stats
[MC 3.0.1] Alerts messages "components" - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2014, 02:19 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Default [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.
Reply With Quote
  #2  
Old 04-15-2014, 09:34 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 04-16-2014, 06:08 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 01-19-2015, 07:35 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Default

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
Reply With Quote
  #5  
Old 01-19-2015, 07:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 01-20-2015, 08:37 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Default

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 ;(
Reply With Quote
  #7  
Old 01-21-2015, 01:46 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Thumbs up

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.
Reply With Quote
Reply

Tags
alert

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:12 AM.


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