When I use a batch process to add a chat response to a non existing annotation file, the file is created in the shared group. (My setting in preference is “In same group” - see below).
If the annotation file exists (in same group) it works as expected and adds the content to the annotation file.
Batch process prompt is to add some characters.
How do I force the batch process to create the annotation file in the same group if it does not exist?
Sequoia and DEVONthink 4.2.2
This is hard-coded into the script, so you need to modify it.
Original:
-- Annotation - Append Text
-- Created by Christian Grunenberg on Thu Aug 01 2024.
-- Copyright (c) 2024. All rights reserved.
on scriptOutput(theRecord, theInput)
tell application id "DNtp"
if theInput is not missing value and theInput is not "" then
set theAnnotation to annotation of theRecord
if theAnnotation is not missing value then
update record theAnnotation with text theInput mode appending
else
set annotation of theRecord to create record with {name:((name of theRecord) as string) & " (Annotation)", type:markdown, content:theInput} in (annotations group of database of theRecord)
end if
end if
try
return plain text of annotation of theRecord
on error
return ""
end try
end tell
end scriptOutput
Quick modification:
property annotationsInSameGroup : true
on scriptOutput(theRecord, theInput)
tell application id "DNtp"
if theInput is not missing value and theInput is not "" then
set theAnnotation to annotation of theRecord
if theAnnotation is not missing value then
update record theAnnotation with text theInput mode appending
else
if annotationsInSameGroup = true then
set targetGroup to location group of theRecord
else
set targetGroup to (annotations group of database of theRecord)
end if
set annotation of theRecord to create record with {name:((name of theRecord) as string) & " (Annotation)", type:markdown, content:theInput} in targetGroup
end if
end if
try
return plain text of annotation of theRecord
on error
return ""
end try
end tell
end scriptOutput
2 Likes
Thank you for helping me overcome my ignorance.
I didn’t think of checking if the script is available for modification. That shows there is always something to learn for me.
Thanks again.
For others wondering where the location for the scripts can be found:
/Users/USERNAME/Library/Application Scripts/com.devon-technologies.think/Script Output
You’re welcome! There’s always more to learn for any of us 
Most of the time I just open the folder from the Scripts menu:
I think the location preference only applies to annotations you create through the standard interface. I don’t see any mention of it in the scripting dictionary.
You can, however, read the user preference directly from the property list file it’s stored in and use that in the script:
-- Annotation - Append Text
-- Created by Christian Grunenberg on Thu Aug 01 2024.
-- Copyright (c) 2024. All rights reserved.
-- Modified by troejgaard on Mar 31 2026
-- to read user’s annotation preference from .plist
property annotationsInSameGroup : missing value
on scriptOutput(theRecord, theInput)
if annotationsInSameGroup is missing value then
tell application "System Events"
set annotationsInSameGroup to value of (property list item ¬
"CreateAnnotationsInSameGroup" of property list file ¬
"~/Library/Preferences/com.devon-technologies.think.plist")
end tell
end if
tell application id "DNtp"
if theInput is not missing value and theInput is not "" then
set theAnnotation to annotation of theRecord
if theAnnotation is not missing value then
update record theAnnotation with text theInput mode appending
else
if annotationsInSameGroup is true then
set targetGroup to location group of theRecord
else
set targetGroup to (annotations group of database of theRecord)
end if
set annotation of theRecord to create record with {name:¬
((name of theRecord) as string) & " (Annotation)", type:¬
markdown, content:theInput} in targetGroup
end if
end if
try
return plain text of annotation of theRecord
on error
return ""
end try
end tell
end scriptOutput
@cgrunenberg Perhaps this could avoid confusing other users in the future? If you like the idea you’re welcome to use it.
(I imagine most people rarely change this setting, so it seems excessive to read from the .plist on every script run. Instead I used a script property to cache the value while DEVONthink is running. I don’t know if that’s actually better in practice.)
1 Like
I think it would be better if the setting “Annotations in same group” would be applied for all annotations created. So that would mean the standard script “Annotation - Append Text” has to use the general setting to avoid confusion.
In my opinion that is what a general setting is about.
@cgrunenberg I hope it is something to be changed for one of the next updates. Thanks.
General settings are for general behaviors, i.e., things you’re doing on your own. Automation is not a general activity and is usually freed from such constraints so people can vary the behaviors, as they need to.
2 Likes