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
NeedHelp55NeedHelp55 

I want to create a event from visulforce page. I uesd a jquery modal box to do that . But standard lookup field,date field,subject field not working.Please Help.

   <style>
    .bottom {
        border:thin solid;
        border-color:black;
     }

    </style>
   
    <script>
        function createActivity()
        {
             $( "#dialog-form" ).dialog({
                  autoOpen: open,
                  height: 400,
                  width: 900,
                  modal: true,
                  buttons: {
                   'Save' : function() {
                       var eventOwner = $('[id$=ownerId]').val();
                      
                       if(eventOwner==''){
                           alert('Owner Cannot be blank');   
                       }
                    },
                   'Cancel': function() {
                       $(this).dialog('close');
                    }
                  }
                });
        }
        function redirectToEvent(eventId){
            alert('Event Id:::'+eventId);
            window.top.location.href = '/'+eventId;
        }
        $( document ).ready(function() {
            alert('Hello');
         });
       
    </script>
   
    <apex:form id="theForm">
        <div id="dialog-form" style="display:none">
            <apex:pageBlock title="New Event" id="pbId">
                <apex:pageBlockSection title="Calendar Details" collapsible="false">
                    <apex:inputField value="{!eventObj.Ownerid}" required="false" id="ownerId"/>
                    <apex:inputField value="{!eventObj.Location}"/>
                    <apex:inputField value="{!eventObj.Subject}"/>
                    <apex:inputField value="{!eventObj.StartDateTime}"/>
                    <apex:inputField value="{!eventObj.WhoId}"/>
                    <apex:inputField value="{!eventObj.EndDateTime}"/>
                    <apex:inputField value="{!eventObj.IsAllDayEvent}"/>
                    <br/>
                    <apex:inputField value="{!eventObj.WhatId}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection collapsible="false" title="Description Information">
                    <apex:inputField value="{!eventObj.Description}"/>
                </apex:pageBlockSection>
            </apex:pageBlock>

        </div>
       
        <apex:outputPanel id="theCalendar">
            <br/>
            <center>
            <apex:commandLink action="{!prev}" rerender="theCalendar">
                <apex:image url="/img/arrow2_picklist_left.gif" style="cursor:pointer;"/>
            </apex:commandLink>
           
            <b>&nbsp;&nbsp;{!month.monthname}&nbsp;&nbsp;{!month.yearname}&nbsp;&nbsp;</b>
           
            <apex:commandLink action="{!next}" rerender="theCalendar">
                <apex:image url="/img/arrow2_picklist_right.gif" style="cursor:pointer;"/>
            </apex:commandLink>
            </center>
            <br/>
            <table width="100%">
                <tr bgcolor="#CCCCCC">
                    <th class="bottom">Sunday</th>
                    <th class="bottom">Monday</th>
                    <th class="bottom">Tuesday</th>
                    <th class="bottom">Wednesday</th>
                    <th class="bottom">Thursday</th>
                    <th class="bottom">Friday</th>
                    <th class="bottom">Saturday</th>
                </tr>
               
                <apex:repeat value="{!weeks}" var="wk" id="foreachWeek">
                    <tr>
                        <apex:repeat value="{!wk.days}" var="day" id="foreachday">
                            <td height="90" valign="top" id="monthdays">
                                <div style="background-color:#E6F8E0;">
                                    {!day.dayofmonth}
                                    <apex:commandLink onclick="createActivity();return false;">
                                        <img src="/s.gif" class="addNewEventIcon"/>
                                    </apex:commandLink>
                                </div>
                              
                                <div>
                                    <apex:repeat value="{!day.eventstoday}" var="v" id="foreachevent">
                                        <span>{!v.formateddate}</span><br/>
                                        <apex:commandLink onclick="redirectToEvent('{!v.ev.Id}');">{!v.ev.subject}</apex:commandLink>
                                    </apex:repeat>
                                </div>
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>
            </table>
         </apex:outputPanel>
    </apex:form>
--------------------------------------------------------------------------

public class Calendar{

    private List<Event> events;
    public Event eventObj{get;set;}
   
    public void prev() {
        system.debug('Hello');
        addMonth(-1);
    }
   
    public void next() {
        addMonth(1);
    }

    public Month month{get;set;}
   
    public Calendar(){
        Date d = System.Today();
        month = new Month(d);
    }
   
    public void addMonth(Integer addMonth) {
        Date d = month.getFirstDate();
        d = d.addMonths(addMonth);
        setMonth(d);
    }
   
    private void setMonth(Date d) {
        month = new Month(d);
        Date[] da = month.getValidDateRange(); // gather events that fall in this month
       
        events = [ select id,subject,description,activitydate,activitydatetime,DurationInMinutes
        from Event
        where activitydate >= :da[0] AND activityDate <= :da[1]
        order by activitydatetime];
       
        System.debug('Events:::::::::::::::::::::'+events);

        month.setEvents(events);  // merge those events into the month class
    }
   
    public List<Month.Week> getWeeks() {
    return month.getWeeks();
  }
}
Ramu_SFDCRamu_SFDC
Try the procedure provided in the below article

http://www.valnavjo.com/blog/modal-dialog-on-a-standard-salesforce-page/