We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get previous appointment data

Suppose I create a new appointment on the schedule.

I want to set the value of a custom field depending on the value of another custom field in the previous appointment. How can I do that?


Appointment 1 (location 1): duration 1hour + the time I need to reach location 1
Appointment 2 (location 2): duration 1 hour + the time I need to reach location 2 from location 1

In order to calculate the time I need to reach location 2, I have to read the location of the previous appointment (location 1)


1 Reply

KK Karthigeyan Krishnamurthi Syncfusion Team February 17, 2017 01:04 PM UTC

Hi Claudio,  
Thank you for contacting Syncfusion support. 
We have prepared the sample to access the previous appointment field values while creating an appointment, which can be download from the below location. 
In the sample when an appointment is saved, BeforeAppointmentCreate event will be raised where your requirement can be achieved. Kindly refer the below code example used in the sample. 
function onBeforeAppointmentCreate(args) { 
        var predicate = ej.Predicate(this._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, new Date(args.appointment.StartTime)); 
        var newAppList = new ej.DataManager(this._currentAppointmentData).executeLocal(new ej.Query().where(predicate)); // app collection before the new added app will be retrived 
        var proxy = this; 
        newAppList.sort(function (a, b) { // sorting the app collection based on start time 
            var d1 = a[proxy._appointmentSettings["startTime"]]; 
            var d2 = b[proxy._appointmentSettings["startTime"]]; 
            return d1.getTime() - d2.getTime(); 
        if (newAppList.length>0) 
        args.appointment["Location"] = 4 + newAppList[newAppList.length - 1].Location; // last app in the collection value is accessed here. 

Live Chat Icon For mobile
Up arrow icon