I’m working on a larger script to move a selected record (group or document) to a particular location in a database, and I need help with what seems like it should be a simple AppleScript idiom. I’ve had success with this:
move record theRecord totheincoming groupof database "Inbox"
in a script that refiles a misplaced record back into the Inbox.
But I’m trying to to move a particular selected record to its “grandparent” group: that is, the group that contains the group that contains the selected record, and I can’t seem to avoid the error:
“Can’t get parent of selected record” (1728)
I have tried a few different approaches to getting the parent group of the selected record (where in the following my_record has been set to the selected record):
e.g.,
setthe_parentto the parent of my_record
or (in case I need to treat parents like a list)
setthe_parentto the first parent of my_record
or (in case I need to be accessing a property)
setthe_parentto (get thelocationof my_record)
or
setthe_parentto thelocation groupof my_record
or even
setthe_parentto the parent whose child is my_record
I must be missing something obvious about correctly accessing the parent of a record. What’s the correct way to get the parent or containing group of a currently selected record?