1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
475 views
by ramaswamy-s-6353 (440 points)
I want to be able to iterate through multiple repetitions of PID 13 - Phone field and add PID 13.3 to indicate if it is home phone or cell phone. For eg. the first repetition would be home phone and I want to add PID13.3 as PH and second repetition would be cell phone and I want to add PID13.3 as CP.

1 Answer

0 votes
//Get PID-13 and split on the tilde
var pid13 = StringUtils.splitByWholeSeparator(message.getNode('PID-13'), '~');
 
//Loop through each instance
for (var i=0 ; i < pid13.length ; i++) {
  
  //Check to see if we have a phone number for Home, Cell, Work and set the appropriate value
   if (message.checkNodeIsNotBlank('PID-13['+(i+1)+'].1')) {
      qie.debug('Inside for loop: ' + i);
      var description;
      switch(i) {
         case 0:
            description = 'PH';
            break;
            case 1:
               description = 'CP';
               break;
               case 2:
                  description = 'WK';
                  break;
      }
      //Set value into message
      message.setNode('PID-13['+(i+1)+'].3', description);
   }
}
by gary-t-8719 (15.1k points)
...