5

I would need to print all the elements of a list so to be able to copy them (CTRL+C) . In Debug Log , I can see only the first 10, or something similar . (a temp solution I'm using is to store them in a Long Area Text field, but I think there's a more efficient solution).

7

I do it like this, if I want to see records in the debug log. Or query for them directly in execute anonymous and debug them from there.

string s = '';
for (record__c r : listOfThings) s += '\n' + r;
system.debug(s);
7

You could use JSON serialization to format all the records in the collection.

E.g.

List<Account> accs = new List<Account>();
for(integer i = 0; i < 50; i++) {
    accs.add(new Account(Name='Account-'+i));
}
System.debug(JSON.serializePretty(accs));
0

you don't need to change code for this. There is a Chrome plugin which shows debug log nicely formatted. This is the link to that plugin: https://chrome.google.com/webstore/detail/apex-debugger/mpckkbblhbfngaininanfjpdfjhbncjo?hl=en

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy