function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Akshay JuwaAkshay Juwa 

Create a list of shipments and parse as well as set up a boolean flag.

Hello Everyone. I'm trying to create a list of shipments for a company. This apex class has a code setup in a way that the reshipment tracking number doesn't get updated over the older shipment. So what I need help is with creating a list of shipments instead of just taking the first one. And parse initialize a Map<String, String> orderLineTrackingNumberMap as well as a boolean flag to indicate if there's been a reship. As we loop thought the ShipmentList, update map's orderLineKey with tracking value (if reshipment, update the parent orderline tracking to new tracking, if this operation happens, update the flag to true.)

The following code snippet needs to be altered.

 Dom.XmlNode trackingXML = detailsXML.getChildElement('ShipmentList', null);
        System.debug('AJ1001 tracking xml:' + trackingXML);
        if(trackingXML!=null)
        {
            trackingXML = trackingXML.getChildElement('Shipment',null);
            System.debug('AJ1001 shipment xml:' + trackingXML);
            if(trackingXML!=null)
            {
                trackingXML = trackingXML.getChildElement('Containers',null);
                if(trackingXML!=null)
                {
                    trackingXML = trackingXML.getChildElement('Container',null);
                }
            }
           
        }
        if(trackingXML!=null)
        {
            detailsParsed.tracking = trackingXML.getAttributeValue('TrackingNo', null);
            System.debug('AJ1001 tracking xml:' + trackingXML);
        }