Hi all I’ve figured how to move a document to the inbox of another database using script, but not how to move it to a specific group in that database without using the group selector. I was expecting something along the lines of
move record theRecord to group "abc" of database "xyz"
but group doesn’t seem to be permissible and the dictionary suggests I can only use incoming group
, which I understand to be the inbox of that database. Is that really the case, or am I missing something?
The documentation (see Script Editor, Library of DT3) is fairly clear:
move record <record> to <record>
A group is a (special kind of) record. So to get the group as a record, you could use something along this line
set theGroup to first item of (records of current database whose name is "group")
provided that there’s only on group with this name in this database.
If you don’t want the current database, who’ll have to to something like
set theDB to root of (first item of (databases whose name is "DB")
and use theDB
in the code above to get the group.
My, this is all so convoluted
Sorry I forgot the conclusion:
move record theRecord to theGroup
should do what you want. If I understand the documentation correctly.
Thanks again I’d love to feel stupid about not knowing that, but although it makes sense reading it, I had read the documentation (and knew how to use
move
) but wouldn’t have figured out what you’ve just shown me in a hundred years
From what you’ve written, I guess (and ask whether you know):
-
records of current database
will contain all records in the database, not just the groups - as you suggested I’d have no trouble so long as I don’t have groups with identical names (I don’t), I assume having a document with an identical name would cause no problem, which in turn suggests that the “list”
records of current database
contains groups first, documents second?
Thank you again - you’re really helping me (and once again, I’m missing the “humble” emoticon)
Actually this is the conventional method…
set dest to get record at "/Markdown/Files" in database "File Types"
move record theRecord to dest
Funnily enough, just the other week I had a matchbox in my hand with exactly that script on the back; it’s just I’d forgotten
Perhaps the two of you might like to move into my guest room for a week or two until I’ve got my head round scripting? Thanks to you too, Jim - I’m very grateful for all your assistance, which quite apart from simply being nice is quite a gleam of hope in these pretty upsetting times.
you might like to move into my guest room for a week or two until I’ve got my head round scripting?
I’m hoping you live in Bali.
Yeah, you and me both
Yes. Records is a generic item, that can be a document, a group or a smart group (and may be other things, too
I doubt that there’s any reliable order in the records
list. My whose
condition was somewhat simplifying - you should add something like and type is group
.
Better, still: use Jim’s approach below using the path to the group. Less typing and easier to understand.