1

I'm trying to save a checkbox value (and eventually a pulldown list of invitee status) with a standard Save button but all it does is refresh the page. I want to update the custom object Event_Attendance__c with the status and Attended checkbox. Here is the code:

<apex:page standardController="Event_Attendance__c" extensions="InviteeListController">
    <apex:sectionHeader title="Event Attendance" subtitle="{!eventDate} - {!eventName}"/>
    <apex:pageBlock title="Invitees" mode="edit">
    <apex:form >
    <apex:actionFunction name="getInvitees" action="{!InsertInvitees}"  rerender="allPanel" />
   <apex:outputPanel id="allPanel">
      <apex:outputPanel rendered="{!NOT(myFlag)}">
     <script>
           window.onload=function()
           {
             getInvitees();
           };
        </script>
      </apex:outputPanel>
     <apex:outputPanel rendered="{!NOT(myFlag)}">
       <apex:pageBlockTable value="{!eventinvitees}" var="eventinvitee">
            <apex:column value="{!eventinvitee.Relation_id__c}"/>
            <apex:column headerValue="Invitation Status" value="{!eventinvitee.Status__c}"/>
            <apex:column headervalue="Attended">
            <apex:inputCheckbox value="{!eventinvitee.Attended__c}"/>
            </apex:column>
        </apex:pageBlockTable>
        <apex:commandButton action="{!Save}" value="Save"/>
            </apex:outputPanel>
    </apex:outputPanel>
</apex:form>
    </apex:pageBlock>
</apex:page>

Here is the controller code: public with sharing class InviteeListController {

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

public InviteeListController(ApexPages.StandardController controller) {
       myFlag=false;

      }


public void InsertInvitees()
{

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

     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){
        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;
        insertinvitees.add(ea);
      }

        insert insertinvitees;
        myFlag = True;
      }
    }
    eventinvitees= [Select Status__c, Attended__c, Relation_id__c, EventID__c, Event__c FROM Event_Attendance__c WHERE EventID__c = :eventid ];
}

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

}

3
  • Can't seem to post the page code.
    – cahigg
    Nov 20, 2014 at 17:28
  • 1
    If you highlight the code and then click the code formatting button your code will show.
    – Jenny B
    Nov 20, 2014 at 18:10
  • does your extension controller have a save() method, and if so, please post the bare essence of that method?
    – cropredy
    Nov 21, 2014 at 2:47

3 Answers 3

1

Calling save on the standard controller is only going to save changes made to the Event_Attendance__c parent record, it won't save changes you're making to the attendees. For that you'll need to use a custom method in your extension.

0

move the button to outside of the outputpanel,use the below code

window.onload=function() { getInvitees(); };

0

You need to create a custom method to update eventInvitee list and call that method from "Save" button using the "Action" attribute in command button.

You must log in to answer this question.

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