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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Filter by custom field value
Pages: [1]

Author Topic: Filter by custom field value  (Read 1467 times)

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Filter by custom field value
July 02, 2013, 07:06:58 am
Is it possible to search by a custom field value? I've added a custom field to events and now I would like to filter according a special value. I've found some information about the api and custom data (http://wiki.civicrm.org/confluence/display/CRMDOC43/Using+Custom+Data+with+the+API) but filtering does not work as described.

I've tried the following rest-url:

http://drupal.demo.civicrm.org/civicrm/api/explorer#/civicrm/ajax/rest?entity=Event&action=get&debug=1&sequential=1&json=1&custom_11=Hello

And also via AJAX:

Code: [Select]
$params = array(
  'version' => 3,
  'sequential' => 1,
  'custom_11' => 'Hello',
);
$result = civicrm_api('Event', 'get', $params);

In both cases the custom parameter does not result filtered data.
« Last Edit: July 03, 2013, 02:16:23 am by PhilippMikael »

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Re: Filter by custom field value
July 04, 2013, 08:38:07 am
It seems that filtering on custom data works only with contacts, but not with events.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Filter by custom field value
July 04, 2013, 11:49:00 am
Hi,

The basic get (that powers more and more of the get api) doesn't handle filter by custom type.

Eileen and I discussed it earlier today, it wouldn't be too difficult to implement an extra join when needed. Do you think you could work on it/sponsor the feature?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Re: Filter by custom field value
July 05, 2013, 04:11:32 am
We have implemented a dirty workaround, because our current project is near the release date. Of course I would prefer an enhancement of the basic get function. How much effort is needed for this?

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Filter by custom field value
March 03, 2015, 06:02:13 am
I created an issue in the issue tracker: https://issues.civicrm.org/jira/browse/CRM-16036.

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Filter by custom field value
March 04, 2015, 01:43:27 am
... and I am working on an implementation: https://github.com/civicrm/civicrm-core/compare/master...johanv:CRM-16036-api_search_custom_fields_3rd_attempt?expand=1

This is still work in progress. At the moment, it is more a proof of concept.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Filter by custom field value

This forum was archived on 2017-11-26.