Is adding attachments to publication items possible via scripting?
Posted: Thu Apr 21, 2022 10:25 am
Hiya. I'm trying to make sure that every file added to a particular DEVONthink group becomes a Bookends publication item.
Creating a publication item is easy:
However, I can't figure out how to add an attachment to the newly-created item in Bookends. I imagine something like the below should work, but it doesn't seem like "make new attachment item" is a thing. Specifically I get the error "Can’t make or move that element into that container." with the following line and a variety of similar attempts:
Here's the full (draft) script:
Any ideas? Or is there something else I can try? Thanks!
Creating a publication item is easy:
Code: Select all
set newPublication to make new publication item with properties {name: "Some name"}
Code: Select all
set newAttachmentItem to make new attachment item with properties {path:recordPath}
Code: Select all
on addRecordToBookends(someRecord)
tell application id "DNtp"
set recordNameWithoutExtension to someRecord's name without extension
set recordName to someRecord's name
set recordPath to someRecord's path
tell application "Bookends"
tell front library window
set newPublicationItem to make new publication item with properties {title:recordNameWithoutExtension as text}
set newAttachmentItem to make new attachment item with properties {name: someName, path:recordPath}
set newPublicationItem's attachments to newAttachmentItem
end tell
end tell
end tell
end addRecordToBookends