-1

I am capturing var TRANSACTION_TYPE =msg['MSH'].['MSH.9'].['MSH.9.2'].toString();

Now I want to check if this value is not equal to A40, like

if ( TRANSACTION_TYPE!=='A40') {
--
--
}

But it is not working

Thanks

skolldev
  • 1,179
  • 9
  • 19
  • 1
    Can you provide more information please? What value does your variables TRANSACTION_TYPE have? – skolldev Apr 17 '19 at 09:51
  • 1
    You aren't specifying what isn't working, but you shouldn't have the periods between your brackets in `msg['MSH'].['MSH.9'].['MSH.9.2'].toString()`. You're probably getting a syntax error before it ever makes it to the comparison. – agermano Apr 17 '19 at 19:07

1 Answers1

1

Seems like it should work. The !== is looking that the variable type is a string as well so that is something to look out for. An easy way to debug issues like this is using either the channelMap or logger.info() for debugging. So I'd advise these lines before your 'if':

logger.info('Debug: typeof(TRANSACTION_TYPE): ' + typeof(TRANSACTION_TYPE));
logger.info('Debug: TRANSACTION_TYPE: ' + TRANSACTION_TYPE);
logger.info('Debug: TRANSACTION_TYPE logic: ' + (TRANSACTION_TYPE !== 'A40'));