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
TheresaAndersonTheresaAnderson 

Compile Error: Initial term of field expression must be a concrete SObject: LIST<Commission__c>

Can someone assist?  I'm receiving the subject error message with the following code.

 

trigger CreateBOM on Commission__c (after insert) {
    List<Commission__c> cpay = new List<Commission__c>();
//    List<Opportunity> copty = new List<Opportunity>();
    for(Opportunity obom : [select Id, Product_Family__C from Opportunity where Id = :cpay.Opportunity_Name__c]){

        for(OpportunityLineItem bomoli : [Select UnitPrice, Quantity, PricebookEntry.Product2.ProductCode,
                                   PricebookEntry.Product2Id, ListPrice, PricebookEntry.Product2.Name, Description
                                   From OpportunityLineItem where OpportunityId = :obom.Id]) {

        If(obom.product_family__c == 'Software'){
            Commission_Request_BOM__c[] ast = new Commission_Request_BOM__c[]{};
            Commission_Request_BOM__c bom = new Commission_Request_BOM__c();
//            for(OpportunityLineItem ol: BOMOLI){
                bom = new Commission_Request_BOM__c();
                bom.Opportunity__c = bomoli.Id;
                bom.Product__c = bomoli.PricebookEntry.Product2.Name;
                bom.Quantity__c = bomoli.Quantity;
                bom.List_Price__c =  bomoli.ListPrice;
                bom.Line_Description__c = bomoli.Description;
                bom.Product_Code__c = bomoli.PricebookEntry.Product2.ProductCode;
                insert bom;
//                }
          }
         }
     }     
}

Starz26Starz26

You are trying to reference the field in a list which you cannot do.

 

change:

 

for(Opportunity obom : [select Id, Product_Family__C from Opportunity where Id = :cpay.Opportunity_Name__c]){

 

to

 

Set<String> oppName = New Set<String>();

 

for(Commission__c c : cpay)

   oppName.add(c.Opportunity_Name__c);

 

for(Opportunity obom : [select Id, Product_Family__C from Opportunity where Id IN "oppName]){

 

 

VasanthKumarVasanthKumar

Set the index value to the Commission__c based on the value retrieval. Something like Commission__c[0].Fieldname