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 CiviMail (Moderator: Piotr Szotkowski) »
  • Sending email to Smart Group that includes all contacts with email
Pages: [1]

Author Topic: Sending email to Smart Group that includes all contacts with email  (Read 1349 times)

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Sending email to Smart Group that includes all contacts with email
December 11, 2008, 04:13:07 pm
HI - any obvious reasons I am having problems with a Smart Group (Email field contains %) when I then use if for a civiMail?

Moving to Step 2 I get this Error - I am not getting errors with other Smart Groups.

Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)
                    LEFT JOIN           civicrm_email
                            ON          civicrm_email.contact_id = contact_a.id
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND (  ( LOWER(civicrm_email.email) LIKE '%%' ) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 431 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=1066 ** Not unique table/alias: 'civicrm_email']
    [type] => DB_Error
    [user_info] => INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)
                    LEFT JOIN           civicrm_email
                            ON          civicrm_email.contact_id = contact_a.id
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND (  ( LOWER(civicrm_email.email) LIKE '%%' ) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 431 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=1066 ** Not unique table/alias: 'civicrm_email']
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)
                    LEFT JOIN           civicrm_email
                            ON          civicrm_email.contact_id = contact_a.id
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND (  ( LOWER(civicrm_email.email) LIKE '%%' ) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 431 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=1066 ** Not unique table/alias: 'civicrm_email']"]
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Sending email to Smart Group that includes all contacts with email
December 11, 2008, 05:19:25 pm
Just to preempt the 'can i relicate it on demo' - i just importe 4,500 records and it seems to work fine. As expected. Any clues for why it failing in our 2.0 set up?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Sending email to Smart Group that includes all contacts with email
December 11, 2008, 10:11:20 pm
This is bug specific to CiviCRM  v2.0.x

left join on civicrm_email table, is repeating twice, hence query break.

This is already fixed in v2.1.

To fix this you will have to make few changes.
1. Modify CRM/Mailing/BAO/Mailing.php

   remove lines 292 and 293

Quote
    LEFT JOIN   $email
             ON     $email.contact_id = contact_a.id

2. Modify CRM/Contact/BAO/SavedSearch.php

 - line around 174
   
Quote
$tables = $whereTables = array( $contact => 1, $email => 1 );
    with
   
Quote
$tables = $whereTables = array( 'civicrm_contact' => 1, 'civicrm_email' => 1 );

Kiran
You Are Designed To Choose... Defined By Choice.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Sending email to Smart Group that includes all contacts with email
December 12, 2008, 01:54:42 pm
Thanks Kiran - Lobo suggested a step around by making Smart Group that includes all contacts which works for me for the Mailing List purpose. cheers
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Sending email to Smart Group that includes all contacts with email

This forum was archived on 2017-11-26.