I have written this code in mirth to capture code from each DG1 segment but it captures 'undefined' and inserts in DB
for each (seg in msg.children()){
if(seg.name().toString()=="DG1"){
var vSET_ID =msg['DG1']['DG1.1'].toString();
if(vSET_ID==1){
var vPriCode = msg['DG1']['DG1.3']['DG1.3.1'].toString(),50);
if(vSET_ID==2){
var vSecCode1 = msg['DG1']['DG1.3']['DG1.3.1'].toString(),50);
Thanks