Answers.Body: <p>I think the API should return the is_deleted! Having said so, if you want to make sure you have the latest version of the activity you could also use the <code>is_current_revision=1</code>?</p>
  
  <p><em>Editing to add a suggestion in the comments also by @ErikH, which was the solution I went for:</em></p>
  
  <blockquote>
    <p>Not sure this is of any help but there is an extension for the
    CaseActivity API: civicrm.org/extensions/caseactivity-api</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-04T19:15:14.207Z
Answers.Text: If that means it hasn't been deleted then that is a good idea. I'll give it a try and get back to you, thanks
Answers.UserDisplayName: naomi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-05T08:06:15.543Z
Answers.Text: The problem happens only with Case activities. For example on the demo try searching for activities with contact id 202 and "is_current_revision". It will return a follow-up activity but if you look on 202's only case you will not see a follow-up activity, because I deleted it. The "is_current_revision" flag is also not returned
Answers.UserDisplayName: naomi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-05T08:12:02.260Z
Answers.Text: Also, "is_current_revision" and "is_deleted" can both be set to 1, so this would not help me to filter out deleted activities
Answers.UserDisplayName: naomi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-08T16:13:23.570Z
Answers.Text: Not sure this is of any help but there is an extension for the CaseActivity API: https://civicrm.org/extensions/caseactivity-api
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-08T22:50:18.810Z
Answers.Text: Thanks @ErikH! That looks like it might do the trick, I'll give it a go.
Answers.UserDisplayName: naomi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-02-04T15:28:56.490Z
Answers.LastActivityDate: 2018-07-10T13:25:50.270Z
Answers.LastEditDate: 2018-07-10T13:25:50.270Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>I had a look on some of my civicrm installs, I didn't find any is_deleted=1 on my activity tables.</p>
  
  <p>Do you have an example of one of your activities with that flag set? Do you have a better result with is_deleted=1 on your data?</p>
  
  <p>and when I use the api explorer with is_deleted=0, I get the is_deleted attribute that is returned. What civicrm version do you have? Can you try to re-produce on the demo site?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-05T08:04:18.517Z
Answers.Text: The problem happens only with Case activities. For example on the demo try searching for activities with contact id 202 and not in trash. It will return a follow-up activity but if you look on 202's only case you will not see a follow-up activity, because I deleted it
Answers.UserDisplayName: naomi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-04T20:57:15.943Z
Answers.LastActivityDate: 2016-02-04T20:57:15.943Z
Answers.UserDisplayName: Xavier
Body: <p>I would like to fetch activities by <code>contact_id</code> and only return non-deleted activities (or, failing that, return them all but filter them afterwards by <code>is_deleted</code>). But I find that passing is <code>is_deleted=0</code> does not make any difference and the <code>is_deleted</code> flag is not present on the returned data.</p>
  
  <p>I guess this is a bug in the API? Is it known? I searched Jira but couldn't see it. If not I will file it and look at submitting a patch.</p>
  
  <p>I can think of one workaround which is to fetch all the activity ids for the contact and then loop through them fetching each activity (since <code>in</code> does not seem to work with activity) by <code>activity_id</code> and <code>is_deleted</code>. But that could be a lot of api calls and means dealing with more async stuff if using JS. Anyone know of a cleaner workaround?</p>
  
Tags: <api><activities>
Title: Deleted flag missing from activities returned from API when getting by contact id
ThreadText: # Deleted flag missing from activities returned from API when getting by contact id
  
  (Asked by: username_0 on 2016-02-04)
  
  I would like to fetch activities by `contact_id` and only return non-deleted activities (or, failing that, return them all but filter them afterwards by `is_deleted`). But I find that passing is `is_deleted=0` does not make any difference and the `is_deleted` flag is not present on the returned data.
  
  I guess this is a bug in the API? Is it known? I searched Jira but couldn't see it. If not I will file it and look at submitting a patch.
  
  I can think of one workaround which is to fetch all the activity ids for the contact and then loop through them fetching each activity (since `in` does not seem to work with activity) by `activity_id` and `is_deleted`. But that could be a lot of api calls and means dealing with more async stuff if using JS. Anyone know of a cleaner workaround?
  
  **Tags:** api, activities
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-02-04. Score: 0 | Accepted answer
  
  I think the API should return the is\_deleted! Having said so, if you want to make sure you have the latest version of the activity you could also use the `is_current_revision=1`?
  
  *Editing to add a suggestion in the comments also by @username_1, which was the solution I went for:*
  
  > Not sure this is of any help but there is an extension for the
  > CaseActivity API: civicrm.org/extensions/caseactivity-api
  
  > **Comments:**
  > **username_0**: If that means it hasn't been deleted then that is a good idea. I'll give it a try and get back to you, thanks  
  > **username_0**: The problem happens only with Case activities. For example on the demo try searching for activities with contact id 202 and "is_current_revision". It will return a follow-up activity but if you look on 202's only case you will not see a follow-up activity, because I deleted it. The "is_current_revision" flag is also not returned  
  > **username_0**: Also, "is_current_revision" and "is_deleted" can both be set to 1, so this would not help me to filter out deleted activities  
  > **username_1**: Not sure this is of any help but there is an extension for the CaseActivity API: https://civicrm.org/extensions/caseactivity-api  
  > **username_0**: Thanks @username_1! That looks like it might do the trick, I'll give it a go.  
  
  ---
  
  ### Answer by username_2 on 2016-02-04. Score: 0
  
  I had a look on some of my civicrm installs, I didn't find any is\_deleted=1 on my activity tables.
  
  Do you have an example of one of your activities with that flag set? Do you have a better result with is\_deleted=1 on your data?
  
  and when I use the api explorer with is\_deleted=0, I get the is\_deleted attribute that is returned. What civicrm version do you have? Can you try to re-produce on the demo site?
  
  > **Comments:**
  > **username_0**: The problem happens only with Case activities. For example on the demo try searching for activities with contact id 202 and not in trash. It will return a follow-up activity but if you look on 202's only case you will not see a follow-up activity, because I deleted it  
  
  ---
  
  