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
vanyavanya 

Event Start/Stop DateTime fields not showing up as editable ... shows up as output string

Code has worked in the past, and suddenly stopped.  I have simplified it as much as possible ...

 

VF Page:

 

<apex:page standardController="Event">
<apex:form> 
Start: &nbsp;&nbsp; <apex:inputField value="{!event.startdatetime}"/><br/>
End: &nbsp;&nbsp;  <apex:inputField  value="{!event.enddatetime}" /><br/>
<apex:commandButton value="Save"  action="{!save}"/>
</apex:form>

</apex:page>

 

Please assist.

 

Vanya

Best Answer chosen by Admin (Salesforce Developers) 
vanyavanya

Thanks for the information.  Andres Perez also responded to a case I had entered which concurs with your statement.  He was able to give me a work around that has fixed my problem (using ActivityDateTime and DurationInMinutes as you suggested).  Hopefully it will be useful to others who are having the same problem.

 

 

<apex:page standardController="Event" extensions="aaPage24"> <apex:form > <apex:messages /> <apex:pageBlock mode="edit"> <apex:pageblockButtons > <apex:commandButton value="Save" action="{!MySave}" /> </apex:pageblockButtons> <apex:pageBlockSection columns="1"> <apex:inputField value="{!Event.Subject}" /> <apex:inputField value="{!Event.StartDateTime}" /> <apex:inputField value="{!Event.EndDateTime}" /> <apex:inputField value="{!Event.ActivityDate}" /> <apex:inputField value="{!Event.ActivityDateTime}" /> <apex:inputField value="{!Event.DurationInMinutes}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> Apex Extension: public class aaPage24 { Event e; ApexPages.StandardController c; public aaPage24(ApexPages.StandardController controller) { c = controller; e = (Event) c.getRecord(); } public PageReference MySave() { e.StartDateTime = e.ActivityDateTime; e.EndDateTime = e.ActivityDateTime.addMinutes(e.DurationInMinutes); c.Save(); return null; } }

 

 Thanks everyone for all of your assistance.

 

Vanya

 

All Answers

WesNolte__cWesNolte__c

Hey

 

I would first check the profiles field level permissions for you profile.

 

Wes 

vanyavanya
Thanks for helping!  I really appreciate it.  I rechecked the security levels.  I'm a sysadmin and the Event start and end datetimes appear to be accessible everywhere I've looked.  I checked Security Controls > Field Accessibility > start > system Admin > Visible (Y), Read only (N), Required (Y).  The specific field security settings under Event are the same.  I have edit access to the event object because the other fields display as input fields.  I am totally at a loss.  Any other ideas?  They will be much appreciated!
sfdcfoxsfdcfox

I suspect that this is a limitation of the current Visualforce representation, since I myself could not get the fields to work either. There appears to be no way under any circumstance to make inputField editable for these two fields. Worse, if you include them and also include a binding to DurationInMinutes or ActivityDateTime, the page becomes unsavable without an extension or custom controller to adjust StartDateTime and EndDateTime so that it coincides with ActivityDateTime and DurationInMinutes.

 

For example:

 

 

<apex:page standardController="Event"> <apex:form> <apex:inputField value="{!event.activitydatetime}"/><br/> <apex:inputField value="{!event.durationinminutes}"/><br/> Start Time: <apex:inputField value="{!event.startdatetime}"/><br/> End Time: <apex:inputField value="{!event.enddatetime}"/><br/> <apex:commandButton action="{!save}" value="Save"/> </apex:form> </apex:page>

 

This page refuses to save if you provide an ID to an existing Event and change either of the editable fields. I'm fairly sure this is not intentional, but... it does not work right now. Using inputText instead makes them "editable", but the "save" problem still occurs. I have no solution to this problem at this time short of writing an extension/controller.

 

vanyavanya

Thanks for the information.  Andres Perez also responded to a case I had entered which concurs with your statement.  He was able to give me a work around that has fixed my problem (using ActivityDateTime and DurationInMinutes as you suggested).  Hopefully it will be useful to others who are having the same problem.

 

 

<apex:page standardController="Event" extensions="aaPage24"> <apex:form > <apex:messages /> <apex:pageBlock mode="edit"> <apex:pageblockButtons > <apex:commandButton value="Save" action="{!MySave}" /> </apex:pageblockButtons> <apex:pageBlockSection columns="1"> <apex:inputField value="{!Event.Subject}" /> <apex:inputField value="{!Event.StartDateTime}" /> <apex:inputField value="{!Event.EndDateTime}" /> <apex:inputField value="{!Event.ActivityDate}" /> <apex:inputField value="{!Event.ActivityDateTime}" /> <apex:inputField value="{!Event.DurationInMinutes}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> Apex Extension: public class aaPage24 { Event e; ApexPages.StandardController c; public aaPage24(ApexPages.StandardController controller) { c = controller; e = (Event) c.getRecord(); } public PageReference MySave() { e.StartDateTime = e.ActivityDateTime; e.EndDateTime = e.ActivityDateTime.addMinutes(e.DurationInMinutes); c.Save(); return null; } }

 

 Thanks everyone for all of your assistance.

 

Vanya

 

This was selected as the best answer
rklaassenrklaassen

Unfortunately this solution does not work for new events. The fields don't show up, I have to use inputText or another workaround :-(