You need to sign in to do that
Don't have an account?
Save error: Initial term of field expression must be a concrete SObject: LIST
I am having a problem with a class I am creating. I keep getting the following error. Any help would be greatly appreciated.
Save error: Initial term of field expression must be a concrete SObject: LIST<Extended_Warranty__c>
public with sharing class BL_extwntylistb {
public List<Extended_Warranty__c> extwnty {get;set;}
public Id extid;
String Name;
public BL_extwntylistb(ApexPages.StandardController controller)
{
extId= controller.getRecord().Id;
try
{
Account ext=[Select id From Account Where id=:extId];
extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c from Extended_Warranty__c where Id =: extwnty.Id ];
}
catch(Exception e)
{
system.debug('Exception'+e);
}
}
}
In the following line:
extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c from Extended_Warranty__c where Id =: extwnty.Id ];
the where clause is passing the 'Id' property of a list
What should that be?
You have two chioces. If you expect the list to have more than one Extended_Warranty__c in the list extwnty, you should perform it like this:
If you believe it is only one, then use this code to get the first item's ID.
I tried both of them and I get no return on any records. I am trying to return all extended warranties from the account that is on a case page. So i think that is why it returns nothing because i need to associate the case account name with the extended warranties.
This is the code now:
public with sharing class BL_extwntylistb {
public List<Extended_Warranty__c> extwnty {get;set;}
public Id extid;
String Name;
public BL_extwntylistb(ApexPages.StandardController controller)
{
extId= controller.getRecord().Id;
try
{
Case ext=[Select id From Case Where id=:extId];
extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c,Ship_To_Company_Name__c,
Sold_To_Company_Name__c,Active_Start_Date__c, End_Date__c from Extended_Warranty__c where Id = :extwnty[0].Id ];
}
catch(Exception e)
{
system.debug('Exception'+e);
}
}
}
JPClark3, How would i put the query below into my class.
SELECT Id, Name,
(SELECT Id FROM Cases),
(SELECT Id, Order_No__c, Ext_wnty_desc__c, Ext_Wnty_Type__c FROM Extended_Warranty__r)
FROM Account
WHERE Id IN (SELECT AccountId FROM Case)
AND Id IN (SELECT AccountId__c FROM Extended_Warranty__c)
public with sharing class BL_extwntylistb {
public List<Extended_Warranty__c> extwnty {get;set;}
public Id extid;
String Name;
public BL_extwntylistb(ApexPages.StandardController controller)
{
extId= controller.getRecord().Id;
try
{
[Select Id From Case where Id IN : Case.AccountId =Extended_Warranty__c.AccountId__c ];
[Select Id From Extended_Warranty__c where Id IN : Account.Id = AccountId ];
}
catch(Exception e)
{
system.debug('Exception'+e);
}
}
}
I can see what you're attempting to do, but when you get a lot of data in your ORG, the WHERE clause will error with too many rows.
OK wyldman, I think I can see what you actually need. The input to your controller class is the account, so you need all the cases and extended warrenties.
I've taken the liberty to rename some of your variables. I'm sure you can name them back. (Just one of my habits).
Wasn't sure of the variable name on Extended_Warranty__c that pointed to the Account, but it looks like you have it as AccountId__c.