# Trigger a message payload based on input from parallel port

**URL:** <https://discourse.nodered.org/t/trigger-a-message-payload-based-on-input-from-parallel-port/12017>\
**Category:** Dashboard\
**Created:** [9 June 2019 23:30 UTC](https://discourse.nodered.org/t/trigger-a-message-payload-based-on-input-from-parallel-port/12017 "2019-06-09T23:30:13Z")\
**Posts on this page:** 1\
**Showing post:** 26

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 June 2019 07:47 UTC](https://discourse.nodered.org/t/trigger-a-message-payload-based-on-input-from-parallel-port/12017/26 "2019-06-12T07:47:44Z")

</div>

Hmmm. I suspect with the lack of screen shots or exported `flow`, we are misunderstanding each other.

**Try this...**

1. Add debug node before and after the function node
  1. SET the DEBUG nodes to output **'complete msg'**

2. Replace the function node code with below.
3. In the debug window, expand the resulting msg `object`s
4. Take Screenshots and post here.
  1. Include the debug window
  2. Include an image showing (at minimum) the region of interest of your flow

**Why..**  
We need to see all properties of the `msg` so we can see why it gets past the `case` statements. So in the debug window we should see what is in `msg.alphaNumeric`.  
I would bet my left nut and several packet of my favorite crisps that the value in `msg.alphaNumeric` IS NOT a match to any of the `case` entries you have.

```auto
//remove all non alphanumeric (and the @) from the input 
//NOTE: store it in msg object so we can inspect it in the debug window
msg.alphaNumeric = msg.payload.replace(/[^a-z0-9@+]+/gi, ''); 
//use switch to populate msg.output based on content of alphaNumeric
switch (msg.alphaNumeric) {
  case "@1T@1XR@1Y10":
  msg.output = "1";
  break;
  case "@1T@1XR@1Y236":
  msg.output = "2";
  break;
  default:
  node.error(`UNKNOWN value in payload '${msg.payload}'. Cannot generate value for msg.output`, msg);
  return null;//halt flow of msg - dont trigger output of this node
}
return msg;//return msg so next node

```

_Lastly, if you want further help, it may be beneficial if you post your flow and sample data. [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)_

---

_[View the full topic](https://discourse.nodered.org/t/trigger-a-message-payload-based-on-input-from-parallel-port/12017)._
