Answers.Body: <p>The answer at the time of writing is that this is not implemented, so you can't use the API for this.</p>
  
  <p>However, work has begun and you need to wait for issue <a href="https://issues.civicrm.org/jira/browse/CRM-16036" rel="nofollow">CRM-16036</a> to be resolved and released.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-21T16:01:28.753Z
Answers.LastActivityDate: 2015-08-21T16:01:28.753Z
Answers.UserDisplayName: artfulrobot
Body: <p>Looking at the API explorer on the <a href="http://d46.demo.civicrm.org/civicrm/api/explorer#explorer" rel="nofollow">demo site</a> it appeared that it's possible to query custom data on activities using the API.</p>
  
  <p>However it seems that while the UI helps you select custom fields and set the values you want to search for, and there's no error submitting that, it seems completely ignored in terms of the query run.</p>
  
  <p>I added a custom field set to Meeting activities on the demo (4.6.8 at 21 Aug 2015) and added a meeting activity with <code>foo</code> in a custom field, then queried this using the API explorer, but it seems to return <em>all</em> activities regardless of the custom_<em>N</em> query.</p>
  
  <p>The <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Using+Custom+Data+with+the+API" rel="nofollow">developer documentation</a> says</p>
  
  <blockquote>
    <p>As with normal API parameters, you can set custom_22 = 'Fred' in a get operation to filter for records that have custom_22 ...</p>
  </blockquote>
  
  <p>So is this a bug/unimplemented feature or am I doing something wrong? Is there a work around or do I go back to writing plain ol' SQL?</p>
  
  <p>Thanks.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-21T14:31:44.643Z
Comments.Text: Possibly linked to [similar question on events](http://civicrm.stackexchange.com/questions/4816/civievent-search-by-custom-field)
Comments.UserDisplayName: artfulrobot
Tags: <api><custom-fields>
Title: How to use the API to query custom fields on activities?
ThreadText: # How to use the API to query custom fields on activities?
  
  (Asked by: username_0 on 2015-08-21)
  
  Looking at the API explorer on the [demo site](http://d46.demo.civicrm.org/civicrm/api/explorer#explorer) it appeared that it's possible to query custom data on activities using the API.
  
  However it seems that while the UI helps you select custom fields and set the values you want to search for, and there's no error submitting that, it seems completely ignored in terms of the query run.
  
  I added a custom field set to Meeting activities on the demo (4.6.8 at 21 Aug 2015) and added a meeting activity with `foo` in a custom field, then queried this using the API explorer, but it seems to return *all* activities regardless of the custom\_*N* query.
  
  The [developer documentation](http://wiki.civicrm.org/confluence/display/CRMDOC/Using+Custom+Data+with+the+API) says
  
  > As with normal API parameters, you can set custom\_22 = 'Fred' in a get operation to filter for records that have custom\_22 ...
  
  So is this a bug/unimplemented feature or am I doing something wrong? Is there a work around or do I go back to writing plain ol' SQL?
  
  Thanks.
  
  **Tags:** api, custom-fields
  
  > **Comments:**
  > **username_0**: Possibly linked to [similar question on events](http://civicrm.stackexchange.com/questions/4816/civievent-search-by-custom-field)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-08-21. Score: 1 | Accepted answer
  
  The answer at the time of writing is that this is not implemented, so you can't use the API for this.
  
  However, work has begun and you need to wait for issue [CRM-16036](https://issues.civicrm.org/jira/browse/CRM-16036) to be resolved and released.
  
  
  ---
  
  