Received: by 10.54.133.5 with HTTP; Wed, 7 Dec 2005 11:56:33 -0800 (PST)
Date: Wed, 7 Dec 2005 11:56:33 -0800
From: Dave Greenberg <caché>
Reply-To: "CiviCRM: General discussion around development" <caché>
To: CiviCRM Developer Community <caché>
Subject: Re: [Crm-dev] Tagging several objects simultaneously
Content-Type: text/plain; charset=UTF-8; format=flowed
Delivery-Date: Wed, 07 Dec 2005 14:57:16 -0500
X-Forwarded-For: caché caché
Received-SPF: neutral (gmail.com: 126.96.36.199 is neither permitted nor denied by best guess record for domain of caché)
DomainKey-Status: bad (test mode)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com;
List-Id: "CiviCRM: General discussion around development"
We'll look at solving the UI based import/tagging problem down the
road a bit. I think your idea of allowing folks to assign tag(s) to an
import set as we do w/ Groups is a good one - at least for some use
For now, you have two choices.
1. We have implemented the Tagging API in 1.3 - so (very soon) you can
use crm_create_entity_tag(&$tag, &$entity) to do this. Details are
2. You can do this directly in SQL. Sample insert query below -
entity_id is contact ID (civicrm_contact.id) - tag_id is
civicrm_tag.id value for the tag.
INSERT INTO civicrm_entity_tag
(entity_table, entity_id, tag_id) VALUES ('civicrm_contact', 3 3)
BTW - we'd love to hear about the project(s) you're migrating/working on!
On 12/7/05, Gregory Heller <caché> wrote:
> It seems like the answer here is to create some custom fields that
> correspond to those fields in your source data, do the import, importing
> you"categories" to the custom field, then do a search and tag operation?
> I have a similar problem as Joshua. I am going to be importing about
> 20k records into civicrm. these records already have "groups" and
> "tags" In the case of my legacy data, there are actualy "contact type"
> "consituency" and "issue" so i have 3 types of data that i am going to
> consolidate into civicrm's groups and tags features. i have 30
> constituencies and 30 issues, and about 18 contact types.
> contact type is s single select field so i am going to map that to group
> on import. (by importing in batches by contact type).
> The consituencies and the issues are going to be the hard ones because
> they are multi select in my legacy data.
> ** Tags are stored as a simple join table - entity_id to tag_id
> can i interface directly with the database and do an insert into the join table for tags (what is that table called?)
> I would of course first have to create all the tags i want to use, and then match their ids to the entity_ids.
> seems to me that you should be able to load a set of contacts and add a tag to them the same way that you can add them to a group. In that scenario i would do my initial load of all contacts, then just reload subsets for each tag.
> Dave Greenberg wrote:
> >At some point we'll implement a tagging API which will make this
> >easier/safer. For now, you'll need to create a script for this - and I
> >can give you a headstart...
> >1. You'll need to retrieve the civicrm_contact.id values corresponding
> >to your primary emails using a query like this:
> >SELECT civicrm_contact.id as contact_id
> >FROM civicrm_contact
> >LEFT JOIN civicrm_location ON ( civicrm_location.entity_table =
> >'civicrm_contact' AND
> > civicrm_contact.id =
> >civicrm_location.entity_id AND
> > civicrm_location.is_primary = 1 )
> >LEFT JOIN civicrm_email ON ( civicrm_location.id =
> >civicrm_email.location_id AND civicrm_email.is_primary = 1 )
> >WHERE civicrm_email.email = '$yourEmailString'
> >2. Browse civicrm_tag to get the id for each tag you want to assign
> >3. Create INSERT query to insert records into civicrm_entity_tag (one
> >for each tag assigned to each contact). Something like
> >INSERT INTO civicrm_entity_tag
> >(entity_table, entity_id, tag_id)
> >('civicrm_contact', $contact_id, $tag_id)
> >It would be great if you could share your script with the dev list
> >once you have something working. I suspect others will be able to use
> >it :-)
> >On 10/11/05, Joshua Nichols <caché> wrote:
> >>caché wrote:
> >>>Input search criteria (basic or advanced search) and click Search
> >>>Select 'Tags Contacts' from the -more actions- dropdown field
> >>>Change radio button to 'all nnn records' and click Go
> >>>Select the tag to assign
> >>>If you still feel you need to do this in SQL or 'outside the
> >>>UI' - let us know.
> >>Thanks Dave!
> >>I still see it as useful to be able to do externally, because it's
> >>trivial for me to get a list of everyone in my outlook contacts that are
> >>in the "Clay Monsters" category, but rather awkward, if not impossible
> >>to duplicate that result set using the standard search tools.
> >>If everything was in only a single category, a careful import would
> >>handle it, but the "Chaotic Evil" category and the "Clay Monsters"
> >>category overlap, but also have non overlapping members. I don't
> >>necessarily want to re-import the overlapping members just to get the
> >>full set of "Chaotic Evil" folks in after I've already imported the Clay
> >>Crm-dev mailing list
> >Best regards,
> >Dave Greenberg
> >CiviCRM Team
> >Try CiviCRM - http://www.openngo.org
> >Crm-dev mailing list
> Gregory Heller
> AIM/SKYPE: GregoryHeller
> The content of this email message is licensed under a
> Creative Commons Attribution-ShareAlike 2.5 License, Some Rights Reserved.
> Get Firefox! The Browser you can trust http://www.mozilla.com
> Reclaim you inbox with Thunderbird! http://www.mozilla.com
> Crm-dev mailing list
Try CiviCRM - http://www.openngo.org
Crm-dev mailing list