1

I'm using VS Code with the salesforce extensions to debug a test method. A query executed by the method is returning no records when I think it should be returning one. So I click on the "Debug Test" link above the test definition, but when I get to where the query string is being defined and try to see its value, all I get is this:

'SELECT Id, Name, (SE (2787 more) ...'

How can I see what the full query string is at that point?

2
  • Is it a static query or a dynamic one? If the former, you should be able to just find it in the code.
    – Adrian Larson
    Commented Sep 13, 2021 at 20:44
  • It's a dynamic query.
    – Chuck
    Commented Sep 13, 2021 at 20:55

2 Answers 2

1

To get the full output, you need to actually use System.debug, as in:

System.debug(queryString);
1

For your example (a simple string), System.debug(value); is sufficient. If the value you want to debug is more complex, such as an array with many entries, an SObject record with long field values, or an apex class with many properties, System.debug() often truncates individual field/property values and/or array members. If you run in this problem, a useful workaround is

System.debug(JSON.serialize(value));

JSON-serialized output is not truncated in the log (unless the whole log is so large it it truncated), although it may be truncated in Developer Console; viewing the raw log or downloading the log will let you see the full value.

Note that this can rapidly increase your log size for very large objects/arrays, but when you just need to see the contents of a variable/expression without truncation, it is a useful option. For large outputs, a JSON formatter may be useful; there are many online.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .