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
close icon

Why isnt Scheduler populated with appointments from my Mongodb server (using Mongoose)?

I am building a MEAN-application with Scheduler. Creating appointments and saving them to the mongodb database works flawlessly, hoewever, the schedulers remains empty while there are many appointments in the database. This is in my index.js


app.post("/GetData", (req, res) => {
Event.find({}, function(err, events) {
res.send(events);
});
});

I see in my Network tab in my browsers developer tools that when the Scheduler is loaded, the 'getData returns a '200 OK' with the request
Running the 'GetData' endpoint in postman gives me these documents:

 {
        "_id""5dc835d6wefw835250ab4456",
        "startTime""Tue Nov 12 2019 12:00:00 GMT+0100 (GMT+01:00)",
        "endTime""Tue Nov 12 2019 12:30:00 GMT+0100 (GMT+01:00)",
        "subject""Work",
        "klant""Simon",
        "km"43,
        "business"true,
        "location""Amsterdam",
        "description""test",
        "__v"0
    }

How does it come that I dont see the appointments in the scheduler?

22 Replies

YL Youssef Lakdime November 10, 2019 07:34 PM UTC

private dataManager: DataManager = new DataManager({
url: 'http://localhost:8000/GetData',
crudUrl: 'http://localhost:8000/BatchData',
adaptor: new UrlAdaptor
});

this is what I have as dataManager


VD Vinitha Devi Murugan Syncfusion Team November 11, 2019 12:24 PM UTC

 
Hi Youssef, 
 
Syncfusion Greetings. 
 
We have tested your shared code in which field mapping is incorrect, which is the root cause of the reported issue. We prepared the sample below with the right field mapping, please refer to it. 
 

 
Regards, 
M.Vinitha devi 



YT yasser taibi May 18, 2022 09:03 AM UTC

Hello

please can someone help me with the execution of the program gives me this time offset in the frontback part of the project but at the database it saves the exact times


img3.JPG

mongoDB 

img2.JPG





RV Ravikumar Venkatesan Syncfusion Team May 19, 2022 02:07 PM UTC

Hi Yasser,


Greetings from Syncfusion support.


We have validated your query based on your shared images and in your DB the appointment start and end times are stored in the UTC format. By default, while assigning this data to the Scheduler it automatically converts the start and end times of the appointment based on the System timezone. Because of that, the Scheduler appointments are rendered in the 11.


Ex: If you are in the UTC +3 Moscow timezone. If the appointment start time is May 19, 2022, at 9 AM in UTC. The Schedule automatically adds three hours to the appointment start time-based on the System's local timezone UTC +3 Moscow. So, the appointment was rendered on May 19, 2022, at 11 AM.


If you want the Schedule to render the appointment at the exact time that is stored in the DB can you kindly share the below details?

  • Are you using the Timezone property of the Schedule?
  • If yes can you share the Timezone property value?


Refer to the below UG for more details about working with Schedule Timezone.

https://ej2.syncfusion.com/angular/documentation/schedule/timezone/


Regards,

Ravikumar Venkatesan



YT yasser taibi June 3, 2022 06:27 AM UTC

Hello,

Please, I need help. I want to save in the database "idUser" to have each activity has a user who created.

I managed to create "idUser" in the database as you see.

==> Code "routes/activity"

sf.jpg

==> database

kh.JPG

Now I want to give the value of "id User", how i pass the value? knowing that I can recover the value and I don't know how to add it ?

==> Code "activity.component.ts"

hfhf.JPG




RV Ravikumar Venkatesan Syncfusion Team June 6, 2022 02:47 PM UTC

Hi Yasser,


We have validated your query “I want to save in the database ‘idUser’” at our end. We suggest you add the IdUser field value to the added or changed appointment data on the actionComplete event of the Schedule as shown in the below code snippet. So, you can get the IdUser field value that will be available at the server end and you can store it in your DataBase.


[app.component.ts]

export class AppComponent {

  public dataRecord<stringany>[] = extend([], zooEventsDatanulltrueas Record<stringany>[];

  public selectedDateDate = new Date(2021115);

  public eventSettingsEventSettingsModel = { dataSource: this.data };

  public currentViewView = 'Week';

 

  public onActionComplete(argsActionEventArgs): void {

    if (args.requestType === 'eventCreated') {

      // This block will execute once an appointment is created

      args.addedRecords[0].IdUser = 'User Id';

    }

    else if (args.requestType === 'eventChanged') {

      // This block will execute once an appointment is edited

      args.changedRecords[0].IdUser = 'User Id';

    }

  }

}


Sample: https://stackblitz.com/edit/ej2-angular-schedule-additing-custom-fields?file=app.component.ts


Kindly try the shared solution and let us know if you need any further assistance.


Regards,

Ravikumar Venkatesan



YT yasser taibi replied to Ravikumar Venkatesan June 9, 2022 11:27 AM UTC

I followed all the steps you suggested !!

==> Code "activity.component.ts"