3

Have tried using API, but $result = civicrm_api3('Contact', 'get', array( 'return' => "id", 'contact_sub_type' => array('!=' => "Parent"), ));

gives zero results, while Search builder gives results using this query:

Contact Subtype Not Like Parent ...AND... Contact Type = 'Individual'

API calls also give zero results count if

 'organization_name' => array('IS NOT NULL' => 1),

and

'current_employer' => array('IS NOT NULL' => 1),

being used, although we know such records exist. Moreover, theree are records, where "Current employer' field is empty, which yet have Relationships.

In theory, it might be possible to compare two arrays (all existent Relationships wjere Contact A is an Individual and all existent Individuals), but it might be tricky a bit at current number of records in both arrays (around 100K in each). So, any reliable way to find Individual Contacts with no Relationships, nor Employers?

5

One way of achieving your goal would be via a temporary group:

  1. Using advanced search, search for all contacts who do have a relationship (simply open the "Relationships" tab, enter nothing, and search - it will default to all active relationships).
  2. Add all the resulting contacts to a group (or make a smart group if you want to save yourself this step in the future).
  3. Using search-builder, find all contacts not in that group.

PS: the "Parent" contact sub-type has nothing to do with relationships. Contact types are quite different in CiviCRM from relationships, and having one does not automatically bestow the other.

  • Sorry it doesn't work unfortunately, Search builder still gives contacts with at least one Relationship. – yurg Oct 19 '15 at 14:16
  • Try the include/exclude custom search – Coleman Oct 19 '15 at 15:37
  • Have tried several conditions, one which did the trick once(!) is " Contact ->Group(s) -> Is null ". Thanks God I've added contacts found in a group than; haven't been able to repeat this since: "Not in group" gives no results (mean, too much results); no luck with 'Is null' / '≠' / 'Is empty' as well. Moreover, it gives "random" results: sometimes it;s an empty set, sometimes it's a couple of records.. – yurg Oct 19 '15 at 17:05
  • Did you try the include/exclude custom search? – Coleman Oct 19 '15 at 18:34
  • 1
    It took me time to realise what "include/exclude custom search" means and where is it. For those who'd be interested, it's here: /civicrm/contact/search/custom?csid=4&reset=1 And this works, thanks! Wish I found it before. – yurg Oct 19 '15 at 19:14
4

Thing which works is "include/exclude custom search" : "Search -> Custom searches -> Include / Exclude Search" or /civicrm/contact/search/custom?csid=4&reset=1 Thanks @Coleman!

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.