Question

I use the following code to add a new entry to my Google calendar using TMS Cloud component I have the new entries in a table in a database and they are added OK But I would like to be able to update an entry also, but that I cant find any help about. The demo that is supplied with the controls has the option, but I don't want to load all entries from the calendar and select the one to edit there. I want to save some sort of entryID that it is given and use that to update. DevExpress has an option that lets you sync a table to and from Outlook calendar (works very nice) so I think it should be possible to do with TMS

The question is: how do I get an ID of a calendar entry when creating it so I can store it with the record in table and use it afterwards for updating?

var
  ci: TGCalendarItem;
begin
      AdvGCalendar.App.Key    := Settings.Google.Key;
      AdvGCalendar.App.Secret := Settings.Google.Secret;
      AdvGCalendar.Logging := true;

      if not AdvGCalendar.TestTokens then
        AdvGCalendar.RefreshAccess;

      if not AdvGCalendar.TestTokens then
        AdvGCalendar.DoAuth
      else
        Connected := True;

      ci := AdvGCalendar.Items.Add;

      AdvGCalendar.GetCalendars();
      ci.CalendarID := Settings.Google.Calendar;
      if ci.CalendarID <> '' then
        begin
          ci.Location     := CiLocation;
          ci.Description  := CiDescription;
          ci.Summary      := CiSummary;
          ci.StartTime    := EncodeDateTime(YearOf(StartDate), MonthOf(StartDate), DayOf(StartDate), HourOf(StartTime), MinuteOf(StartTime), 0, 0);
          ci.EndTime      := EncodeDateTime(YearOf(StopDate), MonthOf(StopDate), DayOf(StopDate), HourOf(StopTime), MinuteOf(StopTime), 0, 0);
          ci.IsAllDay     := False;
          ci.Visibility   := viPrivate;
          AdvGCalendar.Add(ci);
        end;
end;
Was it helpful?

Solution

The problem was related to the fact that there was an error in the version I was using of the component so that the ID was not returned OK.

Upgrading to a newer version fixed this so now it is working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top