First, let's break down the message into manageable parts. Then we can use a series of loops to access each element we need to change.
There are three FT1 segments, so we will need to do the same for each FT1.
Each of these segments have an FT1-19 field. (Fields are separated by the '|' symbol). This is one of those fields:
N95.2^^9~N39.0^^9~N35.9^^9~N81.11^^9
Within an FT1-19 field, there are four values. They are separated by a '~' symbol. Here are the four values:
N95.2^^9
N39.0^^9
N35.9^^9
N81.11^^9
Almost there... Each of these field values have three subfields. (Subfields are separated by '^' symbol). Subfield 3 is the value we want to remove (the "9" at the end of each field value).
At this point, we can build the node path we need. Where "x" defines which FT1 segment (1, 2, or 3, since there are three FT1 segments), and "y" defines which FT1-19 value to use (1, 2, 3, or 4, since there are four FT1-19 values).
FT1[x]-19[y].3
We need to loop through each FT1, and then loop through each value in FT1-19, and then update the third subfield. Here is the code to do this.
//Get all the FT1 segments
var ft1Segments = source.getAllNodes('FT1');
//Loop through each FT1 Segment.
for (var x = 1; x <= ft1Segments.length ; x++) {
//Looping through the mutiple values of FT1-19 (up to 20 times).
for (var y = 1; y <= 20; y++) {
// If the node exists, blank out the subfield 3, otherwise, "break" out of the loop.
if (message.checkNodeExists("FT1[" + x + "]-19[" + y + "].3")) {
message.setNode("FT1[" + x + "]-19[" + y + "].3", "");
} else {
break;
}
}
}