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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

updating Id of a recurrence

Thread ID:

Created:

Updated:

Platform:

Replies:

149337 Nov 22,2019 04:10 AM UTC Nov 29,2019 05:10 AM UTC Angular - EJ 2 6
loading
Tags: Schedule
jose lara
Asked On November 22, 2019 04:10 AM UTC

Hi,  I am trying to update Id of a recurrence, after it is created. Usually, when a recurrence gets created on the scheduler, a random Id is automatically assigned. But, I want to assign my own Id to it, so that I can uniquely identify it using a primary key from the DB. The code below is what I am using. However, the Id of the recurrence remains the same. 

public onActionBegin(args: ActionEventArgs): void {


//Store recurrence in the DB and get the primary key id from DB

this.someService.createRecurrence(this.someModel).then( (response)=>{

 

let data:Object=new DataManager(this.scheduleObj.getCurrentViewEvents()).executeLocal(new Query().where('RecurrenceID', 'equal', args.addedRecords[0]['Id'])); //Find recurrence which was just created

data[0].Id = response['id']; // Re-assign the ID obtained from the DB to the recurrence that just got created  

this.scheduleObj.saveEvent(data[0], 'EditOccurrence'); //Save changes


console.log('before then:' + JSON.stringify(this.scheduleObj.getEvents())) //Id doesn't change even after updating


});


}



Vinitha Devi Murugan [Syncfusion]
Replied On November 22, 2019 09:18 AM UTC

Hi Jose, 
 
Syncfusion Greetings. 
 
If we create the appointment through editor window, we generated the event Id in source end based on maximum id in the scheduler. If you want to maintain your own id you need to maintain the separate field in event object. Please refer below highlighted code and for the same we prepared the below sample.  
 
 
public onActionBegin(args: ActionEventArgs): void { 
    if (args.data) { 
      args.data[0].PrimaryId = args.data[0].Id + 1; // add additional field and set your Id 
    } 
  } 
 
In above sample we maintained PrimaryId field to store the additional information.  
 
Kindly try the above solution and let us know, if you need further assistance on this. 
 
Regards, 
M.Vinitha devi 


jose lara
Replied On November 22, 2019 11:50 PM UTC

If you read my code completely, you will notice that I want to change the Id from within a promise (then method). The code sample you provided does not work within a promise. I would appreciate if you can read my question completely.

    if (args.data) { 
      args.data[0].PrimaryId = args.data[0].Id + 1; // add additional field and set your Id 
    } 

jose lara
Replied On November 26, 2019 12:43 AM UTC

Any updates on this? Basically, I am looking to store the ID that I get from the DB to a newly created event, so that I can keep track of any user interactions with that event, such as updates or deletes to that event. The ID that the scheduler assigns, is not reliable or unique. When a calendar is shared by multiple users, the ID will not be unique. So, I am thinking of assigning the ID my DB is generating, before it gets rendered on the scheduler. 

Vengatesh Maniraj [Syncfusion]
Replied On November 26, 2019 02:33 PM UTC

Hi Jose, 

Sorry for the inconvenience  

We have further reviewed your shared code snippet and found that you've filtered the events from getCurrentViewEvents and updated the event Id that's wrong because it doesn't reflect the change in UI and DB. Instead, we suggest using eventSettings.dataSource to filter the event and change it. Once changes are made, the refreshEvents method needs to be called to refresh the events. Please see the code shown below and we have prepared the sample below. 
 

public onActionBegin(args: ActionEventArgs): void { 
    if (args.data && args.data[0]) { 
      const studentsObservable = this.scheduleService.getId(); 
      studentsObservable.subscribe((scheduleData: any) => { 
        let data: Object = new DataManager( 
          this.scheduleObj.eventSettings.dataSource 
        ).executeLocal(new Query().where("Id", "equal", args.data[0].Id)); 
        data[0].Id = scheduleData.Id; 
        this.scheduleObj.refreshEvents(); 
      }); 
    } 
  } 


Regards, 
Vengatesh  


jose lara
Replied On November 29, 2019 12:46 AM UTC

Great! This is exactly what I wanted. 

Vinitha Devi Murugan [Syncfusion]
Replied On November 29, 2019 05:10 AM UTC

Hi Jose, 
 
Thanks for your update. 
 
We are happy to hear that our solution has fulfilled your requirement.  
  
Regards, 
M.Vinitha devi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon