문제

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.

  • After the debug line "Value=" my for loop is being broken correctly and the debug line "Completed Value=" executes, followed by my function "updateBookingRecordWithConfirmationResponse" followed by the debug line "After updatefunctionCalled". This so far is all correct. What is then happening next is bizarre though.
  • The debug statement "Completed Value=" executes again as does the function "updateBookingRecordWithConfirmationResponse" then the debug line "After updatefunctionCalled" again. This should not happen a second time. My function "walkThroughReservationNode" is not being called again but the debug logs and call to updateBookingRecordWithConfirmationResponse do.

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');
 }
도움이 되었습니까?

해결책 2

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.

다른 팁

Could you please post the stack of debug log messages?

I mean something like that:

dbgMsg1
dbgMsg2
dbgMsg3
....
dbgMsgN

in the order how it has executed, because from your description it isn't fully understandable(use System.debug(LoggingLevel.INFO, 'dbgMsg') for filtering needed dbg messages)

from my side code seems correct, but:

  • what is context of invocation walkThroughReservationNode? Is it VF / trigger / web services / etc.?
  • what does updateBookingRecordWithConfirmationResponse do? Any DMLs which might to invoke walkThroughReservationNode again?
  • How many times System.debug('in walkThroughReservationNode'); has appeared?
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top