Reply
Regular Contributor
Riothamus
Posts: 20
0
Accepted Solution

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);

}

 

 

Moderator
bob_buzzard
Posts: 6,427
0

Re: Embedded variables in Query

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?

--
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter

I don't respond to private messages/emails asking for help.


Take the Bob Buzzard Sobject Fields quiz.

Regular Contributor
Riothamus
Posts: 20
0

Re: Embedded variables in Query

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?

 

 

Moderator
bob_buzzard
Posts: 6,427
0

Re: Embedded variables in Query

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_c...

--
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter

I don't respond to private messages/emails asking for help.


Take the Bob Buzzard Sobject Fields quiz.