Values not updated during Debug Session when "PUT" values

Issue #649 wontfix
Eric Alexander created an issue

When you are performing Dynamic Apex on an sObject and PUTTING a value on the object to modify it, the updated value is not reflected in the debugger variables.

For Example,

sObject a = New Account(Name = 'Test');
a.put('Name','Updated');
System.debug(a.get('Name'));

I understand why as I do not believe the debug logs show the updated value, but can it be inferred from code or something to update the variables. Until I figured this out I was banging my head wondering why my code was not updating the values. Turns out that was not even the issue as the values were being updated.

Screenshots should be in order of:

  1. Construction of sObject
  2. Modification of the Name to Updated
  3. System debug

Screen Shot 2017-07-11 at 10.56.50 AM.png

Screen Shot 2017-07-11 at 10.57.17 AM.png

Screen Shot 2017-07-11 at 10.57.51 AM.png

The variable in the variables window remains 'Test' until I actually Debug it. If I did not debug it then it would not be updated in the Variables window

Comments (5)

  1. Scott Wells repo owner

    Unfortunately there's not much I can do here. The logs show direct variable assignments but not changes that happen by side-effect of system method calls such as collection mutators. There are two workarounds: 1) assign the collection to another variable which is then presented in the logs; 2) add a heap dump breakpoint at the location where you'd like to see the updated collection contents and IC will integrate that heap dump into the variables view.

  2. Scott Wells repo owner

    More like "cantfix" than "wontfix". Unfortunately it's just the nature of log-based debugging.

  3. Eric Alexander reporter

    Figured as much. At least it is here for posterity and maybe someone banging their head debugging will find it and save them some time.

    Just curious though, would you be able to reconcile the put in the debug log with the line of code and "infer" the value and update the variable? Probably too much work and risk to do that though.

  4. Log in to comment