I'm trying to add a field to track event attendance (not just accepted response). I've created a custom object and a visualforce page. The problem I am having is copying the EventRelation data to the custom object if the object doesn't already contain the data. I'm stuck on getting a list from EventRelation and looping through the list to copy the data to a new custom object list with a for loop. I get the error:

Initial term of field expression must be a concrete SObject

I understand that the value is a list and not an SObject but I can't figure out a work around. Code is below:

public with sharing class InviteeListController {

    string eventid=ApexPages.currentPage().getParameters().get('event_id');
    string eventName =  ApexPages.currentPage().getParameters().get('event_name');
    public Boolean myFlag{get; set;}

    public InviteeListController(ApexPages.StandardController controller) {

        eventinvitees= [Select Id, OwnerId, IsDeleted, Name, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, LastViewedDate, LastReferencedDate, Status__c, Attended__c, Relation_id__c, EventID__c, Event__c FROM Event_Attendance__c WHERE EventID__c = :eventid ];

    public void InsertInvitees()
        if (!myFlag)
            Integer inviteecount = [SELECT COUNT() FROM Event_Attendance__c WHERE EventID__c = :eventid];
            if (inviteecount== 0){

                List<EventRelation> getinvitees= [SELECT RELATIONID, EVENTID, STATUS,  RESPONDEDDATE, RESPONSE FROM EventRelation WHERE EVENTID = :eventid];
                List<Event_Attendance__c> insertinvitees = New List<Event_Attendance__c>();
                for (EventRelation a : getinvitees){
                    insertinvitees.EventID__c = a.EVENTID;
                    insertinvitees.Relation_id__c = a.RELATIONID;
                    insertinvitees.Status__c = a.Status;
                    insertinvitees.Event__c = eventName;
                insert insertinvitees;
                myFlag = True;

    public List<Event_Attendance__c>eventinvitees{get; set;}
    public List<EventRelation>getinvitees{get; set;}    
    public List<Event_Attendance__c> insertinvitees{get; set;}

Any help would be appreciated. I did get it to work with getinvitees not being a list, but it only copied one record.

1 Answer 1


You need to have a reference to a single new Event_Attendance__c object that you set the values on and then add that new object to the list that you will insert:

for (EventRelation a : getinvitees){
    Event_Attendance__c ea = new Event_Attendance__c();
    ea.EventID__c = a.EVENTID;
    ea.Relation_id__c = a.RELATIONID;
    ea.Status__c = a.Status;
    ea.Event__c = eventName;
  • I now get an error on the insertinvitees.add(ea) line: Error: InviteeListController Compile Error: Method does not exist or incorrect signature: [SOBJECT:Event_Attendance__c].add(SOBJECT:Event_Attendance__c) at line 29 column 13
    – cahigg
    Nov 20, 2014 at 0:57
  • My mistake. I had tried removing the List for insertinvitees. Changed it back and your code works. Thank you very much.
    – cahigg
    Nov 20, 2014 at 1:04
  • Now I can't seem to get the standard Save button to update the checkbox for Attended. I'm sure I have something out of order but here is the page code:
    – cahigg
    Nov 20, 2014 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .