You need to sign in to do that
Don't have an account?

Help with Simple Custom Object Controller
Hi Everyone,
I am very new to apex development and I'm hoping one of you can help. I'm trying to create a controller that is using what I believe (or hope) is a simple query. I'm attempting to use the case ID to retrieve a list of related records from a custom object that is related to cases. However when I execute the code as it appears below, I get zero (0) records. But, if I hard code a 18-digit ID in query statement, the controller works exactly as I want it to. I suspect the problem has something to do with comparing 18-digit object ID's with 15-digit ID's but I'm not sure how to fix this or this is the actual problem. Can someone tell me what I'm doing wrong?
My code is below.
public class mycustomController { //capture the case id public Id thisCaseId {get;set;} //a list to hold the customer objects for this case public List<custom_object__c> thesecobjects = new List<custom_object__c>(); //get the custom objects into the list public List<custom_object__c> getthesecobjects() { //criteria for the custom objects thesecobjects = [Select ID , Name, Case__r.Id, Case__r.CaseNumber FROM custom_object__c WHERE ID =: thisCaseId ORDER BY Case__c DESC LIMIT 10]; return thesecobjects; } }
It doesnt look like you're setting the thisCaseId variable to anything. To set this, use:
thisCaseId = ApexPages.currentPage().getParameters().get('id');