title: Mirth processing multiple segments
body: <p>Here I am doing some mapping for Next of Kin <code>$('Nok')</code> (<a href="http://i.stack.imgur.com/RbzVA.png" rel="nofollow">see mapping table</a>).</p>
  
  <p>Then to process this I have the Javascript below. The reason that I am trying this was is, at times we get multiple next of kin segments come through. If that is the case, mirth throws error as ‘DETAILS: TypeError: Assignment to lists with more than one item is not supported’</p>
  
  <pre><code>var i = 0;
  msg['NK1'][i]['NK1.3']['NK1.3.1'] = $('NoK')
  
  for each ( nk1 in msg.NK1) {
     nk1 = $('NoK').toString();
     i++;
  }
  </code></pre>
  
  <p>But unfortunately my script doesn’t work. 
  Basically, it doesn’t throw any error, but it doesn’t do what it supposed to do for multiple segment. It does works for a single segment</p>
  
  <p>This my outbound message:    </p>
  
  <blockquote>
    <p>NK1|1|BENNY^BEN^^^MR^^L|&lt;12K1.3.1>22&lt;12K1.3.1>627^^RELTN|PRETTY
    GREEN^LONDON^""^""^GH15 3KW^^^Q36|||^^RELT|20030321|||||||9
    NK1|2|^^^^^^L|SP^^RELTN|41 PIPERS GREEN^LONDON^""^""^NW9
    8UH^^^Q36|||^^RELT|20010923|||||||9</p>
  </blockquote>