Find your content:

Search form

You are here

Initial term of field expression must be a concrete SObject: LIST

 
Share

I've been looking around for awhile now trying to figure out how to fix this and I am unable to locate what could be wrong with this.

I am trying to create 2 objects, one that holds my Sampling Object and one that holds my Product Object. When I build my Sampling Object I want to get all the information where Responsible_for_EVB_Build1 is null so it can be populated from my Product object where it is usually not null. Am I going about this right or is my logic wrong?

List<Sampling__c> sampObj =([SELECT Product__c, Name,Id,Responsible_for_EVB_Build1__c FROM Sampling__c WHERE Responsible_for_EVB_Build1__c = null ]);               
system.debug('Product Object === ' +sampObj);

 List < Product2 > prodObj = new List<Product2>([Select Name,AE2__c From Product2 WHERE Id = : sampObj.Product__c]);        
    system.debug('1stParentsampObj === ' +prodObj);

Attribution to: EricSSH

Possible Suggestion/Solution #1

This line is wrong I think:

List < Product2 > prodObj = new List<Product2>([Select Name,AE2__c From Product2 WHERE Id = : sampObj.Product__c]);        

sampObj is a list - so you can't filter where Id = on a list - you need to use an IN statement. You can try changing it to the line below so that it is filtering for all records IN the sampObj List - but depending on what the Product__c field is, you might need to loop through sampObj to build a unique set of Product Ids, and then filter for that instead

List < Product2 > prodObj = new List<Product2>([Select Name,AE2__c From Product2 WHERE Id IN :sampObj.Product__c]);    

Attribution to: BritishBoyinDC
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31108

My Block Status

My Block Content