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
BobBob 

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

}

cmoylecmoyle

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

BobBob

What should that be?

JPClark3JPClark3

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:

 

extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c From Extended_Warranty__c Where Id IN :extwnty ]; 

 If you believe it is only one, then use this code to get the first item's ID.

 

extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c From Extended_Warranty__c Where Id = :extwnty[0].Id ]; 

 

BobBob

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

}

BobBob

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

}

JPClark3JPClark3
I'll take a look, but that where clause is going to get you into a lot of problems.
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.
JPClark3JPClark3

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

 

public with sharing class BL_extwntylistb
{
   public List<Extended_Warranty__c> ExtendedWarrenties {get;set;}
   public List<Case> Cases {get;set;}

   public Id AccountId;
   String Name;
   public BL_extwntylistb(ApexPages.StandardController controller)
   {
      AccountId = controller.getRecord().Id;

      try
      {
         ExtendedWarrenties = [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 AccountId__c = :AccountId ];
         Cases  = [Select id FROM Case WHERE AccountId = :AccountId];

      }
      catch(Exception e)
      {
         system.debug('Exception'+e);
      }
   }

}

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.