Community
Showing results for 
Search instead for 
Do you mean 
Reply

Activities and Contacts: How to find which contacts are related to an Activity

Astute Commentator
Posts: 168
Country: United States

Activities and Contacts: How to find which contacts are related to an Activity

Hi everyone,

 

This one kind of baffles me.

 

I am trying to get a list of contacts related to an Activity. In the past, I could access this via the ActivityContacts list for the activity.

So if there were 5 contacts in the activity list, I'd get 5 contacts. However, something different now happens:

  1- I create an activity that has 3 Users (Huffman, Anderson, Browser) and 4 other contacts in the database.

  2- Now, the Activity.ActivityContacts list, only has the 3 ACT! Users in the list and NOT the other 4 contacts from the database, for a total of 3 not 7

  3- Even stranger, the Activity.ContactCount gives me a count of 7, which is correct.

 

So, how can I find out the 7 contacts that are related to the activity? I have tried GetActivityContactsFromDB but that returns only the 3 users and not the total 7 contacts.

 

The ActivityContacts list works fine if you add just contacts from the database, EXCLUDING any users. Once you add a user to the list, the ActivityContacts will only list the user and not any of the contacts.

 

Hence, what piece of code will allow me to access the full list of contacts related to an Activity.

 

Thank you in advance.

 

T

 

 

Employee
Posts: 1,163
Country: USA

Re: Activities and Contacts: How to find which contacts are related to an Activity

I did some testing with this, this morning. I'm curious if the activity which you were adding contacts to was a re-occuring activity. Whenever in my tests I captured an activity and the ActivityContacts didn't match the number of activites associated, I had captured the wrong occurrence of a re-occuring activity. I was able to get the list of associated contacts like this:

 

ContactList cl = ActApp.ActFramework.Activities.ActivityContactsAsContactList(activity, null);

 

Where activity is an Activity object

Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Activities and Contacts: How to find which contacts are related to an Activity

Mathew,

 

Thank you for your quick response. I've figured it out.

 

The cunundrum rose when the Activity ContactCount was 7 but the ActivityContacts.Count was 3. That was really weird.

 

Well, the reason for the discrepancy is a permissions issue. When ContactCount for the activity is larger that the ActivityContacts, that means that some of the contacts are not accessible to the user. Hence, the "missing' 4 contacts were basically contacts not accessible to the user.

 

Live and learn.

 

T