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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Like in civicrm_contact_search
Pages: [1]

Author Topic: Like in civicrm_contact_search  (Read 903 times)

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Like in civicrm_contact_search
April 21, 2010, 07:56:10 am
Hello,

I am beginner in using CiviCrm API. (I am using CiviCrm 3.1.3)
Maybe anyone can point me in the right direction.

What I want to mimic in code is:
Create a Search with Search Builder with a LIKE statement to a custom field
And then add the resulting people to a tag.

So I found to these API functions:
civicrm_contact_search
and the TAG function civicrm_entity_tag_add

I am now able to retrieve contacts with "civicrm_contact_search" with the params where fields have a certain value, but is it possible to  use a different operator like LIKE in "civicrm_contact_search" ?
If not, can you point me in a direction how to solve this problem?

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Re: Like in civicrm_contact_search
April 21, 2010, 08:34:54 am
I tried different things, and this one actually works, nice

   $params = array(
                    'custom_12'           => "%Business%",
                    'return.contact_id'   => 1,
                    'return.display_name' => 1,
                    'return.country'      => 1,
                    'return.custom_12'    => 1,
                    );
    $result =  civicrm_contact_search( $params );

Maybe an idea to add this functionality in the API documentation.
« Last Edit: April 21, 2010, 08:36:32 am by CatorgHans »

CatorgHans

  • I post frequently
  • ***
  • Posts: 157
  • Karma: 5
  • CiviCRM version: 4.4
  • CMS version: drupal
Re: Like in civicrm_contact_search
May 12, 2010, 08:51:35 am
But how to use this api call for "IS NULL" and "IS NOT NULL"?

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: Like in civicrm_contact_search
May 12, 2010, 11:23:59 am

we currently do not support

IS NULL / IS NOT NULL

If you are interested in working on this, please ping us on IRC and we can help u get started

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Like in civicrm_contact_search

This forum was archived on 2017-11-26.