Marking a reminder as completed

I was wondering if there is a way to mark a specific Reminder as completed using Scriptable given Shortcuts doesn’t have this option. If the Reminder is a repeat item would this also work the same as physically marking it complete (ie Reminders would add the Reminder again after the designated repeat time?). I’m not great with Javascript so would appreciate any assistance.

1 Like

I have had a go varying some other scripts but I am not sure how I code it to accept the parameter from a Shortcut. I am running ios13 and the latest Scriptable beta. In shortcuts I am using PlainText to put the title of the Reminder. How do I then adjust the JavaScript to include this?

var reminder = args.plainTexts(0);

let all = await Reminder.all();
for (let r of all) {
if (r.title == reminder){
r.isCompleted = true;
r.save();
}
}

Here’s an example showing how you can pass multiple arguments via a URL scheme from a Shortcuts shortcut to a named Scriptable script. You would just specify the name of the reminder as a parameter.

Example Scriptable code
let params = args.queryParameters;
console.log(params.scriptName);
console.log(params.foo);
console.log(params.bar);

Hope that helps.

I am trying to work out how to do it with the Scriptable actions step in the latest ios13 betas of Scriptable and Shortcuts. See images.

What you have in your images looks good.

If you’re trying to pass the parameter that’s on the same line as the run command then you need to read it using args.shortcutParameter.

See examples in the attached images, which also include a line at the end to return to Shortcuts.

1 Like

Thanks so much. I have it working now.

1 Like

@dgold Could you please show how you got it working. I created a scriptable action with your exact code (which I have pasted below) but it doesn’t actually mark the reminder as done.

//Completes the reminder with the title passed in args.shortcutParameter

var reminder = args.shortcutParameter;

let all = await Reminder.scheduled();
for (let r of all) {
    if (r.title == reminder) {
        r.isCompleted = true;
        r.save();
    }
}

Safari.open("shortcuts:///")

I have only found it to work when I specify the reminder details in Scriptable. I’ve struggled with passing them from Shortcuts. Also you might find it easier just to use ToolBox Pro now which has the ability to mark a reminder complete. I am using the following in Scriptable:

const list = ["Title of Reminder"] /The title of the reminder
const cal = await Calendar.forRemindersByTitle("List") //"List" is the reminder list name
let reminders = await Reminder.allIncomplete([cal])
// get all completeted reminders of list "Testing"
 
// loop through list of items
for (var item of list) {
let entry = reminders.filter(reminder => reminder.title == item)
entry[0].isCompleted=true // set completed to false => uncheck
entry[0].save() //save changes
 }
Script.complete()
1 Like

I was just about to tell you that I found the Edit Reminder action from Toolbox Pro. It does everything that I need it to do, so I don’t need to script it in Scriptable anymore.

1 Like

Glad you found a way to do this, but just to follow up on the issue you were having with the Scriptable based approach…

The script I posted above definitely does mark reminders as complete (I use it every day to complete a reminder for my daily task review), but I suspect you may be trying to use it to complete reminders that either are not due today or don’t have a due date at all ?

The await Reminder.scheduled() line specifically only retrieves reminders that are overdue or have a due date of today.

This was by design in my particular use case as I wanted to avoid accidentally clearing future reminders (e.g. if I ran my daily review shortcut twice on the same day then I didn’t want it to complete tomorrow’s reminder).

If you want to be able to complete any reminder then you can modify the script as shown below…

//Completes the reminder with the title passed in the main shortcut parameter

var reminder = args.shortcutParameter;

let all = await Reminder.allIncomplete();
for (let r of all) {
    if (r.title == reminder){
      r.isCompleted = true;
      r.save();
    }
}

Script.complete();
1 Like

Thanks @RogerDowning! Where did you learn the Reminders API. Is there documentation for Scriptable. I couldn’t find any.

Scriptable’s documentation is available online and Iin the app.

https://docs.scriptable.app/

Adding to the reply from @sylumer, there are also a few different ways to get to the documentation from within the Scriptable app, although they are not particularly obvious.

  • From the initial grid of scripts you can tap the settings wheel (top left) and choose Documentation from the resultant menu
  • From within the script editor you can tap the small blue document icon at the bottom left of the Log window
  • If you are using an external keyboard you can also hit cmd D from within the editor

I tend to use the last two methods as they allow you to quickly refer to the documentation while creating a script.

1 Like

I don’t know why I don’t see anyone do this but you can always get input using alerts and a text field. Its really easy to export it as a class method and it works very well

const alert = new UIAlert();
alert.title = “new alert!”;
alert.message = “type something”
alert.addTextField(“type here”, null)
const finishedAlert = await alert.present()
const value = finishedAlert.textFieldValue(0)
console.log(value)
1 Like