web stats
Channel Map vs Connector Map vs Global Map - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 11-30-2015, 07:52 AM
lin_xd lin_xd is offline
OBX.2 Kenobi
 
Join Date: Apr 2008
Posts: 92
lin_xd
Default why source connector can't use channelMap.put()?

hi,all

I use js writer as source connector. I want use a channelmap to store a value and using in other destionation. but say:

2: function $c(key, value) { if (arguments.length == 1) { return channelMap.get(key); } else { return channelMap.put(key, value); } }
3: function $s(key, value) { if (arguments.length == 1) { return sourceMap.get(key); } else { return sourceMap.put(key, value); } }
4: function $gc(key, value) { if (arguments.length == 1) { return globalChannelMap.get(key); } else { return globalChannelMap.put(key, value); } }
5: function $g(key, value) { if (arguments.length == 1) { return globalMap.get(key); } else { return globalMap.put(key, value); } }
6: function $cfg(key, value) { if (arguments.length == 1) { return configurationMap.get(key); } else { return configurationMap.put(key, value); } }
7: function $r(key, value) { if (arguments.length == 1) { return responseMap.get(key); } else { return responseMap.put(key, value); } }
8: function $(string) { try { if(responseMap.containsKey(string)) { return $r(string); } } catch(e){}try { if(connectorMap.containsKey(string)) { return $co(string); } } catch(e){}try { if(channelMap.containsKey(string)) { return $c(string); } } catch(e){}try { if(sourceMap.containsKey(string)) { return $s(string); } } catch(e){}try { if(globalChannelMap.containsKey(string)) { return $gc(string); } } catch(e){}try { if(globalMap.containsKey(string)) { return $g(string); } } catch(e){}try { if(configurationMap.containsKey(string)) { return $cfg(string); } } catch(e){}try { if(resultMap.containsKey(string)) { return resultMap.get(string); } } catch(e){}return ''; }
9: function getAttachments() {return AttachmentUtil.getMessageAttachments(connectorMess age);}
10: function addAttachment(data, type) {
LINE NUMBER: 2
DETAILS: ReferenceError: "channelMap" is not defined.
at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:2 ($c)
at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:44 (doScript)
at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:47
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:527)
at com.mirth.connect.connectors.js.JavaScriptReceiver $JavaScriptReceiverTask.call(JavaScriptReceiver.ja va:159)
at java.util.concurrent.FutureTask.run(FutureTask.jav a:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
Reply With Quote
  #12  
Old 12-03-2015, 08:00 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

There is no channel map available in the JavaScript Reader, because there is no message yet. The job of the JavaScript Reader is to create messages for the channel to consume (or just execute an arbitrary block of code).

The JavaScript Writer is different. It's a destination connector, so in there you do have access to the channel map.

If you want to pass metadata along with your messages in the JavaScript Reader, you can return a RawMessage object (or list of said objects), including a map of variables to inject into the source map. More info in the User API.
__________________
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
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Global code adventsun Development 6 05-02-2008 11:02 AM
Global Variables gauchomike Support 2 02-19-2008 10:31 AM
Access global function afterdark23 Support 4 02-14-2008 03:34 PM
Global map jerchap Support 1 01-30-2008 04:02 PM
Global functions - how to do it? Bleupomme Support 1 06-04-2007 12:29 PM


All times are GMT -8. The time now is 10:42 AM.


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