We are receiving PID segments which may have either no PID-13 field at all, a single PID-13 field, or repeating PID-13 fields.
I need to capture any available PID-13.4 containing an email address, and copy it to PID-26. So far I've been able to make it work *except* when there is no PID-13 field data available at all.
The code below works to copy PID-13.4 (matching on the "@" character to signify email) into PID-26, and also correctly does nothing when no "@" character is found. However, it errors out when there is no PID-13 value at all.
How can I update this to only work when it finds something in PID-13?
I did try expanding the IF statement to (msg['PID'][i]['PID.13'].length > 0) && msg['PID']['PID.13'][i]['PID.13.4'].indexOf('@') > 0), expecting it would look to see if the PID-13 contained any value, but it didn't and also removed the copy function that was working before the change. Basically, it does nothing.
I need to capture any available PID-13.4 containing an email address, and copy it to PID-26. So far I've been able to make it work *except* when there is no PID-13 field data available at all.
The code below works to copy PID-13.4 (matching on the "@" character to signify email) into PID-26, and also correctly does nothing when no "@" character is found. However, it errors out when there is no PID-13 value at all.
How can I update this to only work when it finds something in PID-13?
Code:
(i=0; i < msg['PID']['PID.13'].length() > 0; if msg['PID']['PID.13'][i]['PID.13.4'].indexOf('@') > 0) { (msg['PID']['PID.26']['PID.26.1'] = msg['PID']['PID.13'][i]['PID.13.4'].toString()); }
I did try expanding the IF statement to (msg['PID'][i]['PID.13'].length > 0) && msg['PID']['PID.13'][i]['PID.13.4'].indexOf('@') > 0), expecting it would look to see if the PID-13 contained any value, but it didn't and also removed the copy function that was working before the change. Basically, it does nothing.
Code:
(i=0; i < msg['PID']['PID.13'].length() > 0; if (msg['PID']['PID.13'].length > 0 && msg['PID']['PID.13'][i]['PID.13.4'].indexOf('@') > 0) { (msg['PID']['PID.26']['PID.26.1'] = msg['PID']['PID.13'][i]['PID.13.4'].toString()); }
Comment