1

All,

I am new to Python, and I am having issues updating the reminder_is_set property on calendar items. I am trying to get my calendar items from now and 7 days ahead and turn off the reminders.

I can get the calendar items in the view just fine. I can enumerate the items just fine. I just can't seem to figure out how to update the value and save each item. I looked at the examples and see the bulk update sample, but I don't see where the value is being set between the fetch and the bulk update call. Any and all help appreciated.

calendar_items = account.calendar.view(start=startDate, end=currentDateTime)

calendar_ids = [(i.id, i.changekey) for i in calendar_items]

items_iter = account.fetch(ids=calendar_ids, only_fields='reminder_is_set')
for item in items_iter:
    item.reminder_is_set = False

updated_ids = account.bulk_update(items=[(i, ('reminder_is_set')) for i in calendar_items])
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
jaxmeier
  • 499
  • 4
  • 13

1 Answers1

0

The main problem is that your changes are in items_iter but you are calling bulk_update() with calendar_items which doesn't have the changes.

Here's an example that should work:

update_pairs = []
for item in account.calendar\
        .view(start=startDate, end=currentDateTime)\
        .only('reminder_is_set'):
    if item.reminder_is_set:
        item.reminder_is_set = False
        update_pairs.append((item, ('reminder_is_set',)))

updated_ids = account.bulk_update(items=update_pairs)
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63