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
Faizan Ali 17Faizan Ali 17 

Create a New Event functionality with Visualforce

Hi All,

I would like to create an Event on click of a button. I have made the button however I do not know how to replicate the Event object in Calendar.

 I am finding it difficult to make this work since I am new to Visualforce, any guidance/help will be appreciated!
Button
I want this button to open this whenever I click on it:
Event

VF Page Code:
VF Page

My Controller:
User-added image
 
AnudeepAnudeep (Salesforce Developers) 
You can try something like this
 
<apex:page standardController="Event"  > 
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.5.1.min.js')}"  />
<apex:outputPanel id="myevententry">
 	<apex:messages />
	<apex:form>	
  	Subject:<apex:inputField value="{!Event.Subject}" /><BR />
	Date:<apex:inputField value="{!Event.ActivityDateTime}" /><BR />
	Minutes:<apex:inputField value="{!Event.DurationInMinutes}" /><BR />
	
	<apex:inputHidden id="whatid" value="{!Event.WhatId}" />
	<apex:inputHidden id="eid" value="{!Event.Id}" />
	<apex:commandButton value="Save" action="{!quicksave}" />::{!Event.Id}
  </apex:form>
  <script>
	j$ = jQuery.noConflict();
	function init() {
		var whatid = window.location.href.split("wid=")[1];
		j$("[id$='whatid']").val(whatid);
		if("{!Event.Id}" != "") {
			window.location.href = "/apex/newevent?id={!Event.Id}";
		}
	}
	init();
  </script>
</apex:outputpanel>
</apex:page>