Answers.Body: <p>That is weird :-) I assume you have all permission for custom data? And have you tried using the actual ID's for status_id and activity_type_id?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T15:50:34.363Z
Answers.Text: Yep, I have all permission for the custom data, and I even tried removing the status and activity type filters. Same results. There seems to be a disconnect between what the API explorer does, and how the API actually works.
Answers.UserDisplayName: JuliaK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T16:54:37.300Z
Answers.Text: Well, I was wrong about the permissions. I'm logged in as User 1, but my code isn't running as me. Thank you so much for pointing me in the right direction!
Answers.UserDisplayName: JuliaK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T17:09:22.150Z
Answers.Text: To clarify, permissions solved for my second issue. Walking through the code, it seems like my custom field filters is being ignored. Also, I'm getting back ALL custom fields, not just the one in my return parameter. But I can get the value and filter myself.
Answers.UserDisplayName: JuliaK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-11T17:48:48.247Z
Answers.Text: Glad you got there in the end!
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T11:00:05.617Z
Answers.LastActivityDate: 2016-04-08T11:00:05.617Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I'm trying to get Activity information via the API, but have run into two issues:</p>
  
  <ol>
  <li><p>I cannot seem to filter by a date stored in a custom field. I've tried formatting the date multiple ways ('Y-m-d', 'm-d-Y', 'YmdHis', etc), but it doesn't seem to have any impact. </p></li>
  <li><p>Since I can't figure out to make the filter work, I thought I would do the filtering myself. But I can't seem to get the custom field to be returned in the results. When I try in the API Explorer, I get all kinds of data back for each activity. But when I copy / paste the PHP code, I only get a small amount of activity fields, and definitely not the custom field I need.</p></li>
  </ol>
  
  <p>This is the code from the explorer that isn't working for me when I actually use it in code:</p>
  
  <p>$result = civicrm_api3('Activity', 'get', array(
    'return' => "custom_46",
    'status_id' => "Scheduled",
    'activity_type_id' => "TDY",
  ));</p>
  
  <p>The Explorer shows all activity data for each result. When running the generated PHP code in my code, I only get the Activity ID, Activity Type ID, Status ID, and Source Contact ID.</p>
  
Tags: <api><custom-fields><activities>
Title: Trouble getting Activity Information with api
ThreadText: # Trouble getting Activity Information with api
  
  (Asked by: username_0 on 2016-04-08)
  
  I'm trying to get Activity information via the API, but have run into two issues:
  
  1. I cannot seem to filter by a date stored in a custom field. I've tried formatting the date multiple ways ('Y-m-d', 'm-d-Y', 'YmdHis', etc), but it doesn't seem to have any impact.
  2. Since I can't figure out to make the filter work, I thought I would do the filtering myself. But I can't seem to get the custom field to be returned in the results. When I try in the API Explorer, I get all kinds of data back for each activity. But when I copy / paste the PHP code, I only get a small amount of activity fields, and definitely not the custom field I need.
  
  This is the code from the explorer that isn't working for me when I actually use it in code:
  
  $result = civicrm\_api3('Activity', 'get', array(
  'return' => "custom\_46",
  'status\_id' => "Scheduled",
  'activity\_type\_id' => "TDY",
  ));
  
  The Explorer shows all activity data for each result. When running the generated PHP code in my code, I only get the Activity ID, Activity Type ID, Status ID, and Source Contact ID.
  
  **Tags:** api, custom-fields, activities
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-08. Score: 2 | Accepted answer
  
  That is weird :-) I assume you have all permission for custom data? And have you tried using the actual ID's for status\_id and activity\_type\_id?
  
  > **Comments:**
  > **username_0**: Yep, I have all permission for the custom data, and I even tried removing the status and activity type filters. Same results. There seems to be a disconnect between what the API explorer does, and how the API actually works.  
  > **username_0**: Well, I was wrong about the permissions. I'm logged in as User 1, but my code isn't running as me. Thank you so much for pointing me in the right direction!  
  > **username_0**: To clarify, permissions solved for my second issue. Walking through the code, it seems like my custom field filters is being ignored. Also, I'm getting back ALL custom fields, not just the one in my return parameter. But I can get the value and filter myself.  
  > **username_1**: Glad you got there in the end!  
  
  ---
  
  