1

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?

2 Answers 2

0

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 @ErikH, 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

5
  • 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
    – naomi
    Commented Feb 4, 2016 at 19:15
  • 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
    – naomi
    Commented Feb 5, 2016 at 8:06
  • Also, "is_current_revision" and "is_deleted" can both be set to 1, so this would not help me to filter out deleted activities
    – naomi
    Commented Feb 5, 2016 at 8:12
  • Not sure this is of any help but there is an extension for the CaseActivity API: civicrm.org/extensions/caseactivity-api Commented Feb 8, 2016 at 16:13
  • Thanks @ErikH! That looks like it might do the trick, I'll give it a go.
    – naomi
    Commented Feb 8, 2016 at 22:50
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?

1
  • 1
    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
    – naomi
    Commented Feb 5, 2016 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.