CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Custom custom search
Pages: [1]

Author Topic: Custom custom search  (Read 1086 times)

kenahoo

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.3.16
Custom custom search
August 04, 2010, 08:42:54 pm
Hi,

To mark contacts who should receive our newsletter emails, I want to create a Smart Group with the following criteria:

Code: [Select]
(Contact Type - 'Organization'
 ...OR... Contact Type - 'Individual')
...AND...
(Email LIKE '%@%'
 ...AND... Is Deceased != "1"
 ...AND... Contacts != Press Release recipients
 ...AND... No Bulk Emails (User Opt Out) != 1)

Unfortunately I don't think the Search Builder interface supports building such a query.  The closest I could figure out is:

Code: [Select]
(No Bulk Emails (User Opt Out) != 1
 ...AND... Email LIKE '%@%'
 ...AND... Is Deceased != "1"
 ...AND... Contacts != Press Release recipients
 ...AND... Group Status - "Added"
 ...AND... Contact Type - 'Individual')
OR
(No Bulk Emails (User Opt Out) != 1
 ...AND... Email LIKE '%@%'
 ...AND... Contacts != Press Release recipients
 ...AND... Group Status - "Added"
 ...AND... Contact Type - 'Organization')

But this doesn't actually work, because it will miss any contact that's not in at least one group.

Is there a way for me to just write the query in SQL or similar?  Or maybe use a Custom Search as a Smart Group?

Note that I don't really need to limit to Individuals & Organizations, but that's the first thing a user must select in the Search Builder, so that's where I end up.  What I guess I *really* want is just:

Code: [Select]
Email LIKE '%@%'
 ...AND... Is Deceased != "1"
 ...AND... Contacts != Press Release recipients
 ...AND... No Bulk Emails (User Opt Out) != 1
but I'm not sure whether that's possible.  Any help definitely appreciated!

 -Ken

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Custom custom search
August 05, 2010, 01:28:44 am
Deceased and opted-out contacts should never receive CiviMail mailings (it’s a bug if they do) – given this, would it make sense to simply send the mailings to every contact, excluding the ‘Press Release recipients’ group?
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

kenahoo

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.3.16
Re: Custom custom search
August 05, 2010, 05:18:10 am
In my case I'm not doing a CiviCRM mailing though, I'm exporting a list to Constant Contact (our marketing person likes working with their templates).

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Custom custom search
August 05, 2010, 12:10:51 pm
This approach worked for me in a quick test on the 3.2 demo:
1. Go to the Custom Search -  "Include / Exclude Contacts in a Group / Tag" (community contributed and not in menus by default, but you can add it or just access it via Admin > Customize > Manage Custom Searches). On demo, it's at:
http://drupal.demo.civicrm.org/civicrm/contact/search/custom?reset=1&csid=4

2. Pick all the groups you want to include, and the group (Press Release) you want to exclude. Get your results and create a Smart Group ("All Lists Except PR").
3. Note down the Group ID of this new group
4. Go to Search Builder, and search on:
Individuals -  Group(s) = N (where N is the group ID of the smart group above) + No Bulk Mail !=1
5. Save these results as your mailing export smart group.

Or, you could potentially write your own custom search which handles all the above in a more or less hard-coded way (depending on how often the search criteria / groups need to change).
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Custom custom search

This forum was archived on 2017-11-26.