I am encountering some bizarre behavior for a function I have and I cannot explain what's occurring. I have showed it to a fellow colleague who is baffled by it also.
In my code as included here in my questions.
From the code detailed here if anyone can see where my errors in my code are or what may be causing the processes after the for loop to execute again any help on this would be appreciated.
Thanks in advance.
private void walkThroughReservationNode(DOM.XmlNode envelope) {
System.debug('in walkThroughReservationNode');
ReservationConfirmationWrapper reservationConfirmationWrapper =
new reservationConfirmationWrapper();
for (DOM.XMLNode childNode : envelope.getChildElements()) {
system.debug('in for loop');
if (childNode.getName() == 'UniqueID') {
System.debug('uniqueIDNodeVal=' + childNode.getAttribute('ID', ''));
reservationConfirmationWrapper.bookingId = childNode.getAttribute('ID', '');
} else if (childNode.getName() == 'ReservationID') {
System.debug('Value=' + childNode.getAttribute('ID_Value', ''));
reservationConfirmationWrapper.confirmationNumber = childNode.getAttribute('ID_Value', '');
break;
} else if (childNode.getName() == 'Warning') {
System.debug('Warning Exists ' + childNode.getText());
reservationConfirmationWrapper.warningMessage = childNode.getText();
break;
} else {
system.debug('before new walkthrough');
walkThroughReservationNode(childNode);
}
}
System.debug('Completed Value=' + reservationConfirmationWrapper.confirmationNumber);
updateBookingRecordWithConfirmationResponse(reservationConfirmationWrapper);
System.debug('After updatefunctionCalled');
}
Hi Pavel thanks for your help. I found my error to be due to the lines
} else { system.debug('before new walkthrough'); walkThroughReservationNode(childNode); }
This causes the full walkthrough to occur again thus causing the updateBookingRecordWithConfirmationResponse(reservationConfirmationWrapper); line to be called each time which is not what I should have done.
Thanks for your help.