[solved] AppleScript: Are Smart Groups in DEVONthink 3.6 broken?

Wondering why a script doesn’t work anymore …

Can someone please confirm that

  • a Smart Group is created but it’s broken
  • the command doesn’t return anything
tell application id "DNtp"
	try
		set theGroup to current group
		set theQuery to "kind:any"
		set theName to (theQuery & " in: " & (name of theGroup)) as string
		set theSmartGroup to create record with {type:smart group, search predicates:theQuery, search group:theGroup, name:theName} in theGroup
		
		--> missing value … and no valid smart group is created
		
		open window for record theSmartGroup
		activate
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

I can confirm that, yes - I see the same behaviour. No error message, but a smart group is created with no rules and as such no content. These two conditions search predicates:theQuery, search group:theGroup are not being implemented.

1 Like

Thanks @Blanc. Wow bummer

Can you first create the smart group and then pass it additional properties?

1 Like

the search location seems to be the problem; if you remove search group:theGroup then the search predicates are implemented.

1 Like

YES, this works. Thank you very much :smiley:


tell application id "DNtp"
	try
		set theGroup to current group
		set theQuery to "kind:any"
		set theName to (theQuery & " in: " & (name of theGroup)) as string
		set theSmartGroup to create record with {type:smart group, search predicates:theQuery, name:theName} in theGroup
		set search group of theSmartGroup to theGroup
		open window for record theSmartGroup
		activate
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell
1 Like

@cgrunenberg can comment on this.

1 Like

26 minutes - not bad :smiley: I love this forum!

1 Like

A stupid typo in the latest release, the next release will fix this and til then the workaround suggested by @pete31 is fine.

2 Likes

Could this be my issue too?

Smart Rule:

  • Moves item to specific group from Databases

  • 3.6 -When I try to move the moved item to another group, the item moves back to original group. :upside_down_face:

-Before 3.6 when trying to move an item from the moved location, it never went back to the original group.

  • “original group” = Group where items are moved from Global Inbox

As long as the smart rule doesn’t use scripts, it’s not related. A screenshot of the smart rule would be nice.

“Global Inbox” =Databases

The smart rule searches in all databases for items created today and with names matching a certain criteria. In this case it moves them to group X before synchronisation.

Now suppose you move one of these items from group X to group Y. This would require a new synchronization, I guess. So you are in “Before Synchronization”. It is still today, and the name still matches the criteria, I suppose. So what’s DT supposed to do? It has to move the item back to group X, because it is still today and the name criteria still match, I suppose.

You might want to change the “Search in” to “Inbox” or something else which is not “Databases”.

2 Likes

It wasnt like this before 3.6

Before 3.6 after moving X to Y then if I decided to move to Z it would move.

3.6 now, if I move Y to Z it moves back to Y

X= Databases
Y= Group 1
Z= Gourp 2

Then now it is behaving exactly as the rule says it should. As @chrillek suggested, the only way to be sure your file doesn’t get moved unintentionally is to reduce the scope of the search. Why not set the rule to search in “inboxes” rather than “databases”?

Because at any given time DevonThink is open anywhere(any database)

I have script that saves all current URL from Safari, I just execute it so whatever database is open thats where it lands, it then moves that item to Y-Group, But sometimes I wanna move this item to Z-Group. it used to work fine before 3.6 but now it moves back to Y-Gourp.

Will make some adjustments to see if things work out.

Thank you all.

If you’re doing that with a script, it would be easy to adjust it to save to the global inbox (depending on the configuration of your script, something along the lines of set theInbox to root of inbox; in any case, inbox detonates the global inbox) rather than “anywhere” :wink: that should make the whole process rather more predictable :slight_smile:

1 Like