# Finding All Groups in a Database

**URL:** https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113
**Category:** Automation
**Tags:** automation
**Created:** [May 21, 2022, 9:27pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113 "2022-05-21T21:27:35Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![nickwild](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/nickwild/32/24981_2.png) [@nickwild](https://discourse.devontechnologies.com/u/nickwild)
#### Post date: [May 21, 2022, 9:27pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/1 "2022-05-21T21:27:36Z")

</div>

Hi I am trying to use Applescript to pull all the groups in a database ( to populate a dropdown in an HTMLPrompt so I can assign a new record to one of the existing groups)

Referencing the Dictionary I have tried this…

```auto
tell application id "DNtp"
	set myDBGroups to (name of every parent of database "Test" whose (tag type is group tag))
end tell

```

But this only returns {} when there are existing groups. Do I have the syntax wrong (or something else). Any help gratefully received

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [May 22, 2022, 9:04am UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/2 "2022-05-22T09:04:53Z")

</div>

I don’t have access to DT right now but I guess that I’d look for `type is group`.

---

<div class="post-metadata">

### Author: ![nickwild](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/nickwild/32/24981_2.png) [@nickwild](https://discourse.devontechnologies.com/u/nickwild)
#### Post date: [May 22, 2022, 9:54am UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/3 "2022-05-22T09:54:39Z")

</div>

Great thanks @chrillek. Actually just made an amend it is…

```auto
tell application id "DNtp"
	set myDBGroups to (name of every parent of database "Test" whose (type is group and tag type is not ordinary tag))
end tell

```

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [May 22, 2022, 10:14am UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/4 "2022-05-22T10:14:30Z")

</div>

Just a remark: getting the `name` of a group might be less useful than getting the group itself or its UUIDs. Identical names can occur several times in a database, UUIDs are unique as are the group records themselves.

---

<div class="post-metadata">

### Author: ![nickwild](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/nickwild/32/24981_2.png) [@nickwild](https://discourse.devontechnologies.com/u/nickwild)
#### Post date: [May 22, 2022, 11:20am UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/5 "2022-05-22T11:20:54Z")

</div>

Thanks @chrillek a good point. In my use case I have a pre-set bunch of 5 different groups in each of my databases so I don’t think I will run into this issue.

The KM macro asks the user to select one of 4 databases and then (dependent on the result) the user can selects which group the record is to go into (populated from the above). Another macro can then be run and allow the use to select from a database specific bunch of tags to allocate to the record

This one function alone has enabled me to drop Drafts never mind all teh other cool stuff I can do

---

<div class="post-metadata">

### Author: ![Blanc](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/blanc/32/8008_2.png) [@Blanc](https://discourse.devontechnologies.com/u/Blanc)
#### Post date: [May 22, 2022, 2:10pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/6 "2022-05-22T14:10:42Z")

</div>

I wonder whether you could add a suggested location (so the top suggestion from the AI) to the initial dialog…? That might well save you time.

* * *

I’ve actually just played with `classify` and it seems it only works within a database rather than across databases; so

```auto
tell application id "DNtp"
	set theRecords to the selection
	set theRecord to first item in theRecords
	set theList to classify record theRecord
	return theList
end tell

```

will only propose locations within the database the selected record is currently residing in. As a result, I get no results at all for records within the global inbox. @BLUEFROG is that behaviour intentional? The results are also not the same as the suggestions offered by the \*See Also & Classify" inspector. Is there any way to get those same suggestions in AS?

---

<div class="post-metadata">

### Author: ![mdbraber](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mdbraber/32/5802_2.png) [@mdbraber](https://discourse.devontechnologies.com/u/mdbraber)
#### Post date: [May 22, 2022, 2:22pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/7 "2022-05-22T14:22:04Z")

</div>

> [@Blanc](#):
>
> The results are also not the same as the suggestions offered by the \*See Also & Classify" inspector. Is there any way to get those same suggestions in AS?

It would be great to have access to those, but unfortunately in other threads it has been said that the `classify` command has not changed since DT 1.0

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [May 22, 2022, 2:25pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/8 "2022-05-22T14:25:23Z")

</div>

Criss would have to respond on this but no it’s currently not possible to classify across databases via AppleScript.

- Classification used to only work in a database.
- With DEVONthink 3, classification works across databases.
- With a later point release, we added the option to again only classify in the current database via the checkbox in the See Also & Classify inspector.

It may be just a leftover legacy behavior or it may be intentional for performance reasons. Ye wizard of olde, Criss know. 🙂

---

<div class="post-metadata">

### Author: ![Blanc](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/blanc/32/8008_2.png) [@Blanc](https://discourse.devontechnologies.com/u/Blanc)
#### Post date: [August 6, 2022, 5:55pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/9 "2022-08-06T17:55:34Z")

</div>

Just wanted to bump this towards @cgrunenberg to respond at his leisure; I’ve just stumbled across this weakness in DTs AS capabilities again when trying to script world domination. DT has such powerful AS support, that the inability to get the list of classification suggestions (as displayed in the inspector) via script is almost an anomaly.

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [August 11, 2022, 10:24am UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/10 "2022-08-11T10:24:15Z")

</div>

The next release will support this and revise the commands `compare` and `classify` to easily use all databases.

---

<div class="post-metadata">

### Author: ![Blanc](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/blanc/32/8008_2.png) [@Blanc](https://discourse.devontechnologies.com/u/Blanc)
#### Post date: [August 11, 2022, 2:29pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/11 "2022-08-11T14:29:10Z")

</div>

That is great news, thanks Criss!

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [August 11, 2022, 2:38pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/12 "2022-08-11T14:38:08Z")

</div>

And this will make (slow) workarounds used in scripts like the following ones obsolete:

> [@Putting AI better to work: Moving the item to a Document suggestion](https://discourse.devontechnologies.com/t/putting-ai-better-to-work-moving-the-item-to-a-document-suggestion/61190/4):
>
> Yes, this script does it. However we can’t get the exact same result as displayed in the See Also Inspector because As compare record only compares to the record’s database we have to use compare content which means the script can’t compare images, it needs records with text. This script shows a choose from list with See Also suggestions’ parent groups moves the selected record to the chosen group Properties maxLength: truncate group names at truncateEnd: truncate end instead of midd…

> [@Trying to compare record to a given database](https://discourse.devontechnologies.com/t/trying-to-compare-record-to-a-given-database/24727/22):
>
> I’m trying to compare with record instead of content but it only returns results of the current database. tell application id "DNtp" try set theRecords to selection of viewer window 1 if theRecords = {} then error "Nichts ausgewählt." set thisRecord to item 1 of theRecords set theDatabases to databases set allSeeAlsoResults to {} repeat with thisDatabase in theDatabases #set theContent to plain text of thisRecord #set theResults to compare content theContent to this…

> [@How to export the results list for the "See also & Classify" command](https://discourse.devontechnologies.com/t/how-to-export-the-results-list-for-the-see-also-classify-command/58661/12):
>
> No, I will just copy and past this list in a sample e-mail. This is an example the way I do it. I took an image os results Then I wrote the titles (as @cgrunenberg suggest) Then I wrote the first paragraph (to have an ideia about the context of this text) Finally I wrote the last paragraph (that refers to biography)

E.g. a test revision of _Markdown See Also_ (see support assistant) is much faster and the results are identical to the inspector.

---

<div class="post-metadata">

### Author: ![system](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/4/4e6ff70c96be2eb307a274d890bba8d71ba671b3.png) [@system](https://discourse.devontechnologies.com/u/system)
#### Post date: [August 10, 2025, 2:38pm UTC](https://discourse.devontechnologies.com/t/finding-all-groups-in-a-database/71113/13 "2025-08-10T14:38:17Z")

</div>

This topic was automatically closed 1095 days after the last reply. New replies are no longer allowed.
