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
Sam1980Sam1980 

Initial term of field expression must be a concrete SObject: LIST<Contact> at line 23 column 34.

I am getting Error at the line 23 which is in Bold below

(ContactId = c.Id,CampaignId = '7018000tyyy'));

Here is the whole code
trigger triggerContactCreateCampMember on Contact (after update) {

   List<CampaignMember> CampaignMember = new List<CampaignMember>();
   List<Contact> ContactsToAdd = new List<Contact>();
    
    Set<Id> contId= new Set<Id>();
     if(Trigger.isUpdate)
    //Store Contact ID
    for(Contact contact: Trigger.new)
    {
       if (contact.LeadSource =='Web' ) 
       contId.add(contact.ID);
    }
        List<Contact> c = new List<Contact> ([SELECT c.Id,c.AccountId From Contact c
        WHERE Id IN :contId]);

        for (Contact con : c) {

        if(contId.size() > 0)
       {
       
           CampaignMember.add(new CampaignMember
                    (ContactId = c.Id,CampaignId = '7018000tyyy'));
                      insert CampaignMember;
        }
        }
}


Best Answer chosen by Sam1980
Salesforce WizardSalesforce Wizard

I would start with your capmaignID.
 

That's 11 characters., Valid Salesforce IDs are either 15 or 18 characters long.

So your error likely is implying that your trying to set an ID for a Salesforce Record that is invalid. Double check your value and make sure you're pasting a valid ID.

All Answers

Salesforce WizardSalesforce Wizard

I would start with your capmaignID.
 

That's 11 characters., Valid Salesforce IDs are either 15 or 18 characters long.

So your error likely is implying that your trying to set an ID for a Salesforce Record that is invalid. Double check your value and make sure you're pasting a valid ID.

This was selected as the best answer
Jim JamJim Jam
Change ContactId = c.Id .. to .. ContactId = con.Id .. 

c is your list variable and con are the items within it.