1

I upgraded a site last night from 4.7.13 to 4.7.27, and there's now an error when exporting activites. The error is:

Unknown column 'activity_priority.label' in 'field list']"]

I see where this part of the query is built in the civicrm/CRM/activity/BAO/Query.php file, and indeed there is no activity_priority table in my database.

I'm unable to reproduce the error in a Civi demo, so I'm wondering if its something specific to my local installation.

Is there supposed to be an activity_priority table? If so, how would it be created?

If not, any ideas on what would cause this issue?

EDIT: Here is the entire query:

SELECT contact_a.id as contact_id, contact_a.contact_type  as `contact_type`, contact_a.contact_sub_type  as `contact_sub_type`, contact_a.sort_name  as `sort_name`, contact_a.display_name  as `display_name`, contact_a.do_not_email  as `do_not_email`, contact_a.do_not_phone  as `do_not_phone`, contact_a.do_not_mail  as `do_not_mail`, contact_a.do_not_sms  as `do_not_sms`, contact_a.do_not_trade  as `do_not_trade`, contact_a.is_opt_out  as `is_opt_out`, contact_a.legal_identifier  as `legal_identifier`, contact_a.external_identifier  as `external_identifier`, contact_a.nick_name  as `nick_name`, contact_a.legal_name  as `legal_name`, contact_a.image_URL  as `image_URL`, contact_a.preferred_communication_method  as `preferred_communication_method`, contact_a.preferred_language  as `preferred_language`, contact_a.preferred_mail_format  as `preferred_mail_format`, contact_a.hash  as `hash`, contact_a.source  as `contact_source`, contact_a.first_name  as `first_name`, contact_a.middle_name  as `middle_name`, contact_a.last_name  as `last_name`, contact_a.prefix_id  as `prefix_id`, contact_a.suffix_id  as `suffix_id`, contact_a.formal_title  as `formal_title`, contact_a.communication_style_id  as `communication_style_id`, contact_a.job_title  as `job_title`, contact_a.gender_id  as `gender_id`, contact_a.birth_date  as `birth_date`, contact_a.is_deceased  as `is_deceased`, contact_a.deceased_date  as `deceased_date`, contact_a.household_name  as `household_name`, IF ( contact_a.contact_type = 'Individual', NULL, contact_a.organization_name ) as organization_name, contact_a.sic_code  as `sic_code`, contact_a.user_unique_id  as `user_unique_id`, contact_a.employer_id  as `current_employer_id`, contact_a.is_deleted  as `contact_is_deleted`, contact_a.created_date  as `created_date`, contact_a.modified_date  as `modified_date`, contact_a.addressee_id as addressee_id, contact_a.addressee_display as addressee_display, contact_a.addressee_custom as addressee_custom, contact_a.email_greeting_id as email_greeting_id, contact_a.email_greeting_display as email_greeting_display, contact_a.email_greeting_custom as email_greeting_custom, contact_a.postal_greeting_id as postal_greeting_id, contact_a.postal_greeting_display as postal_greeting_display, contact_a.postal_greeting_custom as postal_greeting_custom, IF ( contact_a.contact_type = 'Individual', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id, civicrm_location_type.id as location_type_id, civicrm_location_type.name as `location_type`, civicrm_address.street_address as `street_address`, civicrm_address.street_number as `street_number`, civicrm_address.street_number_suffix as `street_number_suffix`, civicrm_address.street_name as `street_name`, civicrm_address.street_unit as `street_unit`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, civicrm_address.postal_code as `postal_code`, civicrm_address.geo_code_1 as `geo_code_1`, civicrm_address.geo_code_2 as `geo_code_2`, civicrm_address.name as `address_name`, civicrm_address.master_id as `master_id`, civicrm_address.county_id as county_id, civicrm_address.state_province_id as state_province_id, civicrm_address.country_id as country_id, civicrm_phone.id as phone_id, civicrm_phone.phone_type_id as phone_type_id, civicrm_phone.phone as `phone`, civicrm_phone.phone_ext as `phone_ext`, civicrm_email.id as email_id, civicrm_email.email as `email`, civicrm_email.on_hold as `on_hold`, civicrm_email.is_bulkmail as `is_bulkmail`, civicrm_email.signature_text as `signature_text`, civicrm_email.signature_html as `signature_html`, civicrm_im.id as im_id, civicrm_im.provider_id as `im_provider`, civicrm_im.provider_id as provider_id, civicrm_im.name as `im`, civicrm_openid.id as openid_id, civicrm_openid.openid as `openid`, civicrm_worldregion.id as worldregion_id, civicrm_worldregion.name as `world_region`, civicrm_website.id as website_id, civicrm_website.url as `url`, civicrm_activity.id as activity_id, activity_type.value as activity_type_id, activity_type.label as activity_type, civicrm_activity.subject as activity_subject, civicrm_activity.activity_date_time as activity_date_time, activity_status.label as activity_status,
  civicrm_activity.status_id as status_id, civicrm_activity.duration as activity_duration, civicrm_activity.location as activity_location, civicrm_activity.details as activity_details, civicrm_activity.source_record_id as source_record_id, civicrm_activity.is_test as activity_is_test, civicrm_activity.campaign_id as activity_campaign_id, civicrm_activity.engagement_level as activity_engagement_level, source_contact.sort_name as source_contact, activity_priority.label as activity_priority,
  civicrm_activity.priority_id as priority_id  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)  LEFT JOIN civicrm_phone ON (contact_a.id = civicrm_phone.contact_id AND civicrm_phone.is_primary = 1)  LEFT JOIN civicrm_im ON (contact_a.id = civicrm_im.contact_id AND civicrm_im.is_primary = 1)  LEFT JOIN civicrm_openid ON ( civicrm_openid.contact_id = contact_a.id AND civicrm_openid.is_primary = 1 ) LEFT JOIN civicrm_location_type ON civicrm_address.location_type_id = civicrm_location_type.id  LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id  LEFT JOIN civicrm_worldregion ON civicrm_country.region_id = civicrm_worldregion.id  LEFT JOIN civicrm_activity_contact
                  ON ( civicrm_activity_contact.contact_id = contact_a.id )  LEFT JOIN civicrm_activity
                  ON ( civicrm_activity.id = civicrm_activity_contact.activity_id
                  AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 ) INNER JOIN civicrm_contact
                  ON ( civicrm_activity_contact.contact_id = civicrm_contact.id and civicrm_contact.is_deleted != 1 ) LEFT JOIN civicrm_option_group option_group_activity_status ON (option_group_activity_status.name = 'activity_status') LEFT JOIN civicrm_option_value activity_status ON (civicrm_activity.status_id = activity_status.value
                           AND option_group_activity_status.id = activity_status.option_group_id )  LEFT JOIN civicrm_option_group option_group_activity_type ON (option_group_activity_type.name = 'activity_type') LEFT JOIN civicrm_option_value activity_type ON (civicrm_activity.activity_type_id = activity_type.value
                           AND option_group_activity_type.id = activity_type.option_group_id )  LEFT JOIN civicrm_website ON contact_a.id = civicrm_website.contact_id LEFT JOIN civicrm_activity AS parent_id ON civicrm_activity.id = parent_id.parent_id
    LEFT JOIN civicrm_activity_contact ac
                  ON ( ac.activity_id = civicrm_activity_contact.activity_id AND ac.record_type_id = 2)
    INNER JOIN civicrm_contact source_contact ON (ac.contact_id = source_contact.id) WHERE  (  (  (  ( contact_a.sort_name LIKE '%smith%' ) OR  ( civicrm_email.email LIKE '%smith%' )  )  )  )  AND (contact_a.is_deleted = 0) AND  civicrm_activity.id IN ( 25008,25006,25005,25004,25002,25001,24999,24997,24995,24993,24992,24991,24989,24987,24986,24985,24984,24982,24981,24979,24978,24976,24975,24974,24973,24971,24970,24968,24967,24965,24964,24962,24960,24959,24958,24957,24956,24954,24952,24953,24951,24949,24947,25003,25000,24899,24945,24998,24996,24990 )  AND contact_a.is_deleted != 1  GROUP BY civicrm_activity.id  LIMIT 0, 100000;
1

Comparing your SQL to the code, there's certainly a bug, but I can't replicate it on my end. The select method understands that the priority should be included; the from method does not. I don't think this is easily solved without a live debugger.

As a workaround, I'm 95% sure that this error won't occur if you explicitly select the fields to export (instead of exporting "primary fields". It's tedious, but easily tested by just exporting 1-2 fields plus the priority field.

| improve this answer | |
  • Thanks for your help! I found the source of the issue -- the code for this functionality had been overwritten in civicrm_php, and I neglected to look there to update code when upgrading civi. So, not a civi issue at all. – JuliaK Dec 3 '17 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.