Here I am doing some mapping for Next of Kin $('Nok')
(see mapping table).
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>
var i = 0;
msg['NK1'][i]['NK1.3']['NK1.3.1'] = $('NoK')
for each ( nk1 in msg.NK1) {
nk1 = $('NoK').toString();
i++;
}
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
This my outbound message:
NK1|1|BENNY^BEN^^^MR^^L|<12K1.3.1>22<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