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

[n00b] Saving VF page problem, and issues with events

I'm trying to use Visualforce to do one thing: update the owner of X events in bulk.


My initial attempt failed as it appears that Events don't work as either Standard Controllers or as list methods through a Custom Controller.  Ugh.


So I put that attempt on hold and tried something a little more basic: showing all of the Event items through an Opportunity Standard controller and allowing the user to manually edit multiple records on one page (we don't enable Inline Editing at our organization).  Here's the VF code:



<apex:page StandardController="Opportunity"> <apex:form> <apex:pageBlock title="Reassign Events" mode="edit"> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.Events}" var="e"> <apex:column> <apex:inputField value="{!e.Subject}"/> </apex:column> <apex:column> <apex:inputField value="{!e.ActivityDate}"/> </apex:column> <apex:column> <apex:inputField value="{!e.OwnerId}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>


 Unfortunately, when I hit "Save" the changes I make to each Event are not saved.  What am I missing here?  I tried looking to see if the recordSetVar parameter was required, but the documentation is horrible at explaining alternate use cases for that parameter.  All of their examples match the StandardController with the RecordSetVar and don't explain what it means to change it.



Anyways, if anyone knows what I need to change to get this to work, let me know.


Also, if anyone knows if it's possible to update Events entirely through a CustomController class without passing them to the Visualforce page, let me know as well!


Thanks :)


This is because the standard controller is for the Opportunity. It is saving the opp, not the events.


To achieve what your are trying to do I think you will most likely need to setup an extension or custom controller.


Thanks, TehNrd... I'd figured it was something like that, but was hoping there was a workaround.


So what is the most efficient way to update a list of Events connected to an Opportunity with Visualforce?  To all ye VF gods, help me!

Message Edited by Bard09 on 08-03-2009 04:30 PM

I reckon you could use a controller extension that implements a save function.  The first thing to do in the your impelmentation of the save function would be to call the standardController save function.  Then,  you could loop through the events for that record and do what ever it is you want to do them, then save the lot of them with an update.





Thanks for your response, DevAngel.  Unfortunately, I'm stuck on how precisely to loop through the events I've gathered on my VisualForce page in the Extension.  Given that I'm not working with a Custom Controller-based List in my VisualForce code, how can I create a list of the Events generated from the Standard Controller?


For example, the following code works in the extension I'm working on:

opp = (Opportunity)stdController.getRecord();

But add an 's' to create getRecords() and the whole thing falls apart.  Even then, I'm not sure I'd be able to iterate on the results to get any related Event objects.


Any suggestions?






Bump....  Really desperate for help here. Here's my core problem in one sentence:


How do I instantiate the list of Events shown on my VisualForce page (StandardController="Opportunity") in my Extension?


If it's possible to acquire the list of events in the Extension, it'd be trivial to save/update them there.  I just can't figure out how to get them there.