I have an Applescript that has been working for several years, and recently is breaking because of an error.
For context, I run this script when I have a group selected. The subroutine below creates a subgroup within the selected group and returns the location of that new group
tell application "DEVONthink 3"
set open_group to current group
tell open_group
set open_location to create location (location & "/" & name & "/" & "@import") in database
end tell
end tell
return open_location
When I run the Applescript, the create location part of the line is highlighted and I receive the following error:
DEVONthink 3 got an error: Invalid argument db number -50
DEVONthink 3.6 introduced a new handling of “invalide arguments”, they are reported now instead of ignored.
You can’t tell open_group just in database, instead use either
in its database
or
remove it completely as it is not needed (create location defaults to the current database)
I always escape everything after location as in case of slashes in the name you would end up with a nested group structure instead of a group whose name is e.g. test/1.
tell application id "DNtp"
set open_group to current group
tell open_group
set open_location to create location location & (my replace_String(name, "/", "\\/")) & "/" & "@import"
end tell
end tell
return open_location
on replace_String(theText, oldString, newString)
local ASTID, theText, oldString, newString, lst
set ASTID to AppleScript's text item delimiters
try
considering case
set AppleScript's text item delimiters to oldString
set lst to every text item of theText
set AppleScript's text item delimiters to newString
set theText to lst as string
end considering
set AppleScript's text item delimiters to ASTID
return theText
on error eMsg number eNum
set AppleScript's text item delimiters to ASTID
error "Can't replaceString: " & eMsg number eNum
end try
end replace_String