Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Creating appointments with a "New" button
posted

I am trying to open the AppointmentAdd.aspx file by way of a button instead of the standard double click method.  I saw this was in a demo "Full Page Sample" in the sample browser, but I am having trouble implementing it.

I tried using some of the script in the demo, but get an error that ScheduleInfo has no properties.

 <script type="text/javascript">

<!--

function bttnNew_Click(){

 

 

// create a new appointment

var scheduleInfo = ig_getWebScheduleInfoById("WebScheduleInfo");

var dateTime = new Date();

var appointment = scheduleInfo.getActivities().createActivity();

var minutes = dateTime.getMinutes();

if(minutes < 30)

dateTime.setMinutes(30);

else

dateTime.setHours(dateTime.getHours() + 1,0);

appointment.setStartDateTime(dateTime);

scheduleInfo.showAddAppointmentDialog(appointment,
"");}

 

-->

</script>

 

 

Any suggestions?

  • 5118
    posted

    Hello,

    Sounds like the variable scheduleInfo is not getting set and is null... check the id of the WebScheduleInfo... make sure you haven't placed it in a naming container (panel, template, using master pages, etc.) as that will change the ids on you.  Here's a little "trick" i've adopted when you cannot get an initialize event for the control/component on the client side:

    this.ClientScript.RegisterClientScriptBlock(this.GetType(), "WebScheduleID block", "var myScheduleInfoId = '" + this.WebScheduleInfo1.ClientID + "';", true);

    This will render the ClientID as it is defined and you never need to hardcode your control IDs in your client script calls.

    Next, update your script as follows:

    var scheduleInfo = ig_getWebScheduleInfoById(myScheduleInfoId);

    and it should work as you expected.