Reminder : how to remove a due date?

Hi,

I can remove alarms of a specific reminder with:

reminder.removeAlarms();

Is there a way to remove a due date too ?

I tried with:

delete reminder.dueDate;

Or:

reminder.dueDate = undefined;

Or:

reminder.dueDate = null;

But none of these instructions worked.

Would you have any other idea ?

1 Like

Do not forget reminder.update(); after the change

But I think that might be a strange application interface glitch.

@agiletortoise - do you know the twist to solve it?

(… deleting the reminder and creating a new one is the work around for it…)

Yes, reminder.update() is instructed.

Indeed, deleting the reminder and creating a new one would be ok if it’s not possible to simply remove the due date.

I tried running through setting the due date to null and undefined like you did, and tried forcing a property deletion, but like your tests, none were successful.

I think (as in this really is a guess) the issue here is that you don’t actually want to change the value of the due date per se, but rather, you want to disable the options for specifying the due date. These show as checkboxes in a reminder, and it is modifying these checkboxes that I think is unavailable to the reminders scripting object in Drafts as it currently stands.

2020-11-18-15.39.00

Based on that, I would see the only practical workaround to be, as previously suggested, to copy the properties of the existing reminder, delete it, and recreate it anew, but without the due date (/time) properties being set. I think when they are set, it might set these other properties that are not directly accessible.

yes @sylumer your guess is correct. I want to completely get rid of the due date ; manually, it means I want to uncheck the checkbox of date (and time btw) exactly like in this screenshot:

It seems the current reminders scripting object in Drafts does not allow this.

The workaround to delete the reminder and create a copy of it without the due date can only be manual. I think the scripting object in Drafts does not allow to delete an existing reminder.

My guess is more about how reminders works internally.

Agreed and is what I indicated previously.

True. It looks as though you can’t delete, but it is easy enough to mark it as complete which should be a viable alternative to deletion. Here’s an example that does that.

const list = ReminderList.findOrCreate("Test List");
let reminder = list.createReminder();
reminder.title = "Lorem Ipsum";
reminder.notes = "Foo Bar";
let dtToday = new Date();
reminder.dueDate = dtToday.add(1).day();
reminder.update();

alert("go check your reminders list");

aremIncomplete = list.incompleteTasks;
let reminderNew = list.createReminder();
reminderNew.title = aremIncomplete[0].title;
reminderNew.notes = aremIncomplete[0].notes;
reminderNew.update();

alert("go check your reminders list");

reminder.isCompleted = true;
reminder.update();

alert("go check your reminders list");

Should you need to ensure that the task does not appear on a list after deletion, you could also move it off to a special trash list that you can exclude.

The last part above would then become:

const list2 = ReminderList.findOrCreate("Trashed");
reminder.list = list2;
reminder.isCompleted = true;
reminder.update();

alert("go check your reminders list");

Not what I would call elegant, but functional with what’s currently available.

1 Like

Yes @sylumer. And I cross fingers for @agiletortoise to enrich the reminders object if the Apple part makes it possible :wink: