Reminder location/geofence getting messed up - is this script doing it

I have a script I use to automatically “un-complete” a set of reminders in a list in the reminders app. Unfortunately, the geofence is getting screwed up. I want the geofence to remain unmolested so that the next time I cross the geofence boundary, the reminder goes off again. The reminder is getting marked as incomplete, but when I go to look why I didn’t get the expected reminder when I arrive at work, I notice that the geofence is set to my “work” location, but on the map, the pin is off the coast of Africa.

Here’s the relevant portion of the script:

	tell application "Reminders"
			repeat with theRem in (reminders in list myList whose completed is true)
				tell theRem
					delete remind me date
					set completed to false
				end tell
			end repeat
		on error errmsg
			display dialog errmsg buttons {"Cancel", "Continue"} default button 2 giving up after 5
		end try
	end tell

I have the “delete remind me date” in there because any past remind me dates are no longer relevant. Would taking that out fix the issue? I can’t very easily test if it would without taking a long walk.

I wrote this Reminder with geofence script five years ago.

OK. I see you have a script that sets a geofence trigger using static hardcoded long. & lat. coordinates. That may be useful to try and reverse engineer what’s going on here. Hopefully I can retrieve the geofence settings from the reminder before the script corrupts them, so that I can reset them after marking them as incomplete, but I’m still not sure why the geofence settings are getting corrupted in the first place. Any idea why that would be?

I wrapped the “delete remind me date” in a conditional for “if remind me date is not missing value”. I’ll see if that works.

Although, I could not (for whatever reason) precisely reproduce the issue through testing (i.e. create a test reminder with a geofence, complete it, run the script, & check the geofence settings). In my testing, I had the following outcomes on repeated attempts:

  1. Geofence was completely deleted (once)
  2. Geofence was not deleted (every other time)

Perhaps there’s a difference when the geofence trigger has been tripped. It’s difficult to test that in a timely fashion. And I can’t explain why the geofence was deleted the first time and not any other time… :rolleyes:

Ho boy. OK. I tested on the computer that usually runs the script and I reproduced the issue exactly. I think that the easiest solution would be to upgrade the OS on that computer. I’m guessing that the reason I couldn’t reproduce the issue on this computer is because it’s running Mojave and the one that causes the issue is running Sierra.

OMG. So I upgraded the computer yesterday to Mojave. The script still manages to screw up the geofence settings. I don’t know what the missing component is here… First of all, the script takes a long time to run. It takes like a minute or so. Second, it seems to strip out the geofence entirely in Reminders on the computer, but my phone still shows a geofence reminder is set (for when I arrive at work), but when you go to look at the work address, the map is centered on a point off the coast of Africa roughly on the equator. Maybe that’s 0,0 lon,lat coordinates?

I was resetting the address on my phone and the issue would recur. I tried once however setting the geofence in the reminders app on the computer in question and re-ran the script and that time, it didn’t get messed up. So… perhaps this is a 1-time issue with old left-over reminders? I have yet to try this on a new reminder.

However, it would be nice to have a foolproof solution. How do I grab the geofence settings from an existing reminder so I can restore them after making a change that wipes them out?