Announcement

Collapse
No announcement yet.

How to delete repeating fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to delete repeating fields

    I have a field like ORC|NW1~NW2~NW3|....

    which translates to:
    <ORC>
    <ORC.1>
    <ORC.1.1>NW1</ORC.1.1>
    </ORC.1>
    <ORC.1>
    <ORC.1.1>NW2</ORC.1.1>
    </ORC.1>
    <ORC.1>
    <ORC.1.1>NW3</ORC.1.1>
    </ORC.1>

    ...


    How do I delete the second repeating field, so the output ends up being ORC|NW1|..., because when I try delete mst['ORC']['ORC.1']['ORC.1.1'][1] I end up with ORC|NW1~|...

  • #2
    If you just want to pull out a single value to use in a variable, do a javascript step in your source transfer similar to:

    Code:
    if (msg['ORC'].length()>0)
    {
      channelMap.put('my_variable_name', validate( msg['ORC'][0]['ORC.1']['ORC.1.1'].toString() , '', new Array()));	
    }
    else
    {
     if (msg['ORC']==0)
    	{
    	channelMap.put('my_variable_name', validate( msg['ORC'][0]['ORC.']['ORC.1.1'].toString() , '', new Array()));	
    	} 
    else
    {
     channelMap.put('my_variable_name', validate('', '', new Array()));
    }
    }
    (not tested)

    This covers the case if there are 0, 1 or more repeating segments.

    You can also loop through the segments and grab what you need that way.

    Comment


    • #3
      I am receiving an an ORU messa,ge whith multiple ORC.1 values. I want to send on the message intact, except I only want 1 ORC.1 value to be sent.

      Comment


      • #4
        Ran into this same problem today. To remove all but the first repetition:

        Code:
        for(idx = msg['SEG']['SEG.3'].length() - 1; idx > 0; idx --)
        {
          delete msg['SEG']['SEG.3'][idx];
        }
        Jon Bartels

        Zen is hiring!!!!
        http://consultzen.com/careers/
        Talented healthcare IT professionals wanted. Engineers to sales to management.
        Good benefits, great working environment, genuinely interesting work.

        Comment

        Working...
        X