Filtering nested trigger data

I am currently returning orders from magento. Within each order there is a pair of address nodes. Each have an address type of either billing or shipping.

I want to pass the entire order but with the address nodes, if I use those fields it will pass both addresses as an array (I only want the billing).

Is there a way to filter the node in the automation itself or do I need to pass both and handle it within the action?

I didnt know if there was a way to say delete node where address_type = shipping prior to using the data in the action.

Here is an example of the data for reference.

<addresses>
  <data_item>
    <region>Palau</region>
    <postcode>19103</postcode>
    <lastname>Doe</lastname>
    <street>2356 Jody Road Philadelphia, PA 19103</street>
    <city>PA</city>
    <telephone>610-634-1181</telephone>
    <country_id>US</country_id>
    <firstname>John</firstname>
    <address_type>billing</address_type>
    <prefix></prefix>
    <middlename></middlename>
    <suffix></suffix>
    <company></company>
  </data_item>
  <data_item>
    <region>Palau</region>
    <postcode>19103</postcode>
    <lastname>Doe</lastname>
    <street>2356 Jody Road Philadelphia, PA 19103</street>
    <city>PA</city>
    <telephone>610-634-1181</telephone>
    <country_id>US</country_id>
    <firstname>John</firstname>
    <address_type>shipping</address_type>
    <prefix></prefix>
    <middlename></middlename>
    <suffix></suffix>
    <company></company>
  </data_item>
</addresses>

I know I can use the emit nth array element to get a single value but I am looking to emit the entire node without having to use the emit 20 times to get each value

Hi Brent,

I recommend modifying the trigger so that each address type with its associated fields get emitted as separate mappable data fields.

The way to do that is to append the text value from the <address_type> subnode into the name of the <data_item> node, so that it would become <data_item_billing> and <data_item_shipping>. Then the Trigger - Extract Data Fields module will be able to parse them out as needed.

The easiest way to do this would be with a little bit of inlined Java code in the trigger.

Let us know if you need more help!

ok that is a good idea. i didnt think of modifying it within the trigger.

Thanks

Hi Robert,

Is there a specific VTD call for renaming a node or do I need to create a new node and assign all the data there?

I assume I can do a list of nodes and a for loop then within each loop append the value of the type field to the name and rename the node. just not sure what the rename call would be.

EDIT: Nevermind. I am good. I didnt realize there was a data node rename uniquely module. Side idea to that. if that module allowed you to specify a subnode value as the unique naming, that would be great.

The VTD call is theNode.setName(“new name”).

Yes, this scenario happens from time-to-time, will consider making a module to handle this.