web stats
Problems setting channel metadata from postprocessor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2018, 09:31 AM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default Problems setting channel metadata from postprocessor

Hi,

I'm calculating the channel execution time on the channel's postprocessor script.

If I try to set a variable mapped to the channel's metadata using channelMap.put() from the channel postprocessor I get an invalid operation error.

If I add the execution time using responseMap.put that works but the value doesn't appear in my metadata.

Channel metadata looks like this:

Column name=EXEC_TIME
Type=NUMBER
Variable Mapping=exec_time

On my channel postprocessor script I tried

channelMap.put('exec_time', 1234);


This is the error for that:

Wrapped java.lang.UnsupportedOperationException
at 2de13d52-355c-481a-bd2f-9c43d7ff7d0c_Postprocessor:80 (doScript)
at 2de13d52-355c-481a-bd2f-9c43d7ff7d0c_Postprocessor:85
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:527)
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executePostprocessorScripts(JavaScriptUtil.j ava:255)
at com.mirth.connect.server.transformers.JavaScriptPo stprocessor$JavaScriptPostProcessorTask.doCall(Jav aScriptPostprocessor.java:104)
....


Then I tried:

responseMap.put('exec_time', 1234);

Execution is OK, but on the logs screen my metadata column EXEC_TIME is empty.


How can I set metadata columns from a channel postprocessor?

Thanks.
Reply With Quote
  #2  
Old 01-16-2018, 09:41 AM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

BTW I'm using 3.4.2
Reply With Quote
  #3  
Old 01-20-2018, 02:36 PM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

Quote:
Originally Posted by ppazos View Post
BTW I'm using 3.4.2
Any ideas why this code fails?
Reply With Quote
  #4  
Old 01-21-2018, 04:56 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 557
kirbykn2 is on a distinguished road
Default

I don't believe the channelMap is available in a post-processor. Populate your variable with a globalChannelMap and see if that works.
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3
Reply With Quote
  #5  
Old 01-21-2018, 05:57 AM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

It is available for reading, but gives an exception when it's written.

IMO since the channel post processor is pay of the channel execution, the channel map should be available for writing channel metadata variables, like in my use case.

GlobalChannelMap variables would be overwritten by multiple executions of thesame channel in parallel, wouldn't it?
Reply With Quote
  #6  
Old 01-21-2018, 06:09 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 557
kirbykn2 is on a distinguished road
Default

You might want to take at the user guide.

"The map is isolated to the current message as it processes through the channel". You are trying this in the post-processor, The name post-processor makes me believe it is after processing.

I haven't tested this, I could be wrong.

As far as the globalMap, it depends on your configuration. This could be configured so messages don't overwrite the variables.
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3

Last edited by kirbykn2; 04-20-2018 at 08:01 AM.
Reply With Quote
  #7  
Old 01-21-2018, 01:44 PM
odo odo is offline
OBX.3 Kenobi
 
Join Date: Feb 2017
Location: Luxembourg
Posts: 137
odo is on a distinguished road
Default

The postprocessor is executed outside the channel scope - after the destination received the response (if any response is sent by the external system). This also means the metadata is already written at this point of time.

Thus, if you want to set a metadata that appears in the dashboard based on a value that is only available in the postprocessor, you can create a second, subsequent destination and write the value there to the channelmap.
Reply With Quote
  #8  
Old 01-26-2018, 03:52 PM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

Thanks Odo, that might work.

Is there a way to access the start/end dates in the channel source and destinations metadata?

Mirth sets those values by default but it is not clear how to access those from script or transformer code in order to calculate execution times.

Thanks
Reply With Quote
  #9  
Old 04-19-2018, 10:43 PM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 75
ppazos
Default

It seems timestamps from channel metadata can't be accessed from JS code.
Reply With Quote
Reply

Tags
channel, metadata, postprocessor

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 03:21 AM.


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