function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RiothamusRiothamus 

Embedded variables in Query

This method gets an Account object using an object_id, but it is throwing an exception. I know the object_id exists, because I get it from an Account object stored in the database (the code is used in an @future method, so I can't use the object).

 

Why would this be failing? Is it syntax in the SELECT statement?

 

protected override object getObjectById(Id object_id) {
  List<Account> account_scope = [SELECT Id FROM Account Where Id = :object_id];
  return account_scope.size() == 0 ? null : account_scope.get(0);

}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

In the developer console you can also produce heap dumps at regular points.  See:

 

https://na6.salesforce.com/help/doc/en/code_dev_console_view_code_editor.htm#code_dev_console_view_code_enable_heapdump_capture

All Answers

bob_buzzardbob_buzzard

As you are using static apex, the syntax is validated at compile time.

 

When you say fail, what do you see?  Is it a return value of null?

RiothamusRiothamus

Hi Bob,

Sorry to be late getting back to you. I was getting an exception, but I think that I was tracing it to the wrong place in the code. This is now working.

 

I'm relatively new at Salesforce and finding the debugging tools a little lacking. The primary method I've used is to log messages, run it in the Developer Console, and check the log file for results. Is there other methods I could be using?

 

 

bob_buzzardbob_buzzard

In the developer console you can also produce heap dumps at regular points.  See:

 

https://na6.salesforce.com/help/doc/en/code_dev_console_view_code_editor.htm#code_dev_console_view_code_enable_heapdump_capture

This was selected as the best answer