I want to do some spring cleanup and see who in my individual contacts aren't in any group, is there an easy way to do it?
The best solution would be to use search builder like so:
However as Laryn noted there was a bug preventing this from working. I've filed an issue for this, and worked up a fix that hopefully will make it into the next release.
This is a workaround, but it will get what you need with minimal effort. Use the Import Contacts feature. On the first screen, choose Update. Instead of a CSV file as the source, use the SQL query option like so:
SELECT c.ID AS InternalContactID FROM c9.civicrm_contact c WHERE c.contact_type = 'Individual' AND NOT EXISTS ( SELECT 1 FROM c9.civicrm_group_contact c2 WHERE c2.contact_id = c.id) AND NOT EXISTS ( -- don't forget to check smart groups SELECT 1 FROM c9.civicrm_group_contact_cache c3 WHERE c3.contact_id = c.id);
Map the field if it isn't already, and continue to the next screen. Here, you can add the contacts to a group or assign a tag. Click Import Now and you have a "No Group" group that your users can work with.
This technique with Import gives us a full-featured Search Builder for the SQL-savvy.
The easiest is probably to install the extension I just created, thanks to Nicholai magic sql suggestion:
Otherwise, the clunkier way I found is to use the custom search exclude/include and select every group in the exclude fields.
It works, with two issues still - it does include organisations (that are often without a group) - it's a bit of a pita to select all groups when you have more than a handful