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) »
  • Query multiple activities by their IDs
Pages: [1]

Author Topic: Query multiple activities by their IDs  (Read 502 times)

coopersquare

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
    • Cooper Square Committee
  • CiviCRM version: 4.4.4
  • CMS version: Wordpress 3.8
  • MySQL version: 5.1
  • PHP version: 5.3.3
Query multiple activities by their IDs
November 05, 2013, 10:15:58 am
Hi,

We are a tenant advocacy organization, our largest use of Civi is to document interactions with clients.

I accidentally imported a set of activities twice, and there are 136 activities I want to delete. I have all 136 Activity IDs; is there any search function which would return all activities whose ID's match any of "4519 5110 5121 etc." ?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Query multiple activities by their IDs
November 05, 2013, 10:37:17 am
Search builder can (sort of) do that. But you can't delete activities from there - so doesn't seem like that helps. Is there some other property of the duplicate activities that you can search in via Find Activities ??
Protect your investment in CiviCRM by  becoming a Member!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Query multiple activities by their IDs
November 05, 2013, 10:37:43 am
you can use the api to delete these activities in a loop. if u r familiar with sql, you can also use the mysql command line to do so (but do take a backup in case u mess up etc)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

coopersquare

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
    • Cooper Square Committee
  • CiviCRM version: 4.4.4
  • CMS version: Wordpress 3.8
  • MySQL version: 5.1
  • PHP version: 5.3.3
Re: Query multiple activities by their IDs
November 05, 2013, 10:46:02 am
Dave, no unfortunately, I can't discern any characteristic of the activities.  Heck if Advanced Search had a field for Activity ID, I could put in a % and it would at least show me a list I could select them from.

Lobo, I am not too familiar with SQL, do you know the basic form of the command I'd write and I can look into modifying it for my purposes?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Query multiple activities by their IDs
November 05, 2013, 11:58:50 am

Code: [Select]
DELETE FROM civicrm_activity WHERE id IN ( 101, 103, 106 );

please test / take backups / no guarantees / use with care etc

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

coopersquare

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
    • Cooper Square Committee
  • CiviCRM version: 4.4.4
  • CMS version: Wordpress 3.8
  • MySQL version: 5.1
  • PHP version: 5.3.3
Re: Query multiple activities by their IDs
November 05, 2013, 12:20:27 pm
Donald, that did it! Thanks so much!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Query multiple activities by their IDs

This forum was archived on 2017-11-26.