Community
Showing results for 
Search instead for 
Do you mean 
Reply

Add to or create a ContactList or MutableEntityList

Accepted Solution Solved
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom
Accepted Solution

Add to or create a ContactList or MutableEntityList

Hi,

 

I think my brain isn't working this Friday! If I have an array or collection of Contacts is it possible to convert them into a ContactList?

 

Would it be a silly feature request to ask for an Add(List<MutableEntity>) method to be included in the ContactList/UntableEntityList object?

 

 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog

Accepted Solutions
Solution
Accepted by topic author vivek
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: Add to or create a ContactList or MutableEntityList

There isn't a cast available to convert from a list of contacts to a ContactList, nor would most standard collection types have a ToContactList method unfortunately. Also, because of the type of collection that the contact list is based on, it also doesn't have an add method. 

 

Rather than adding an add method to the ContactList type, it may be preferable to just add another collection type based on List rather than an array, and have a method for this type to convert to ContactList.

Matthew Wood
Act! SDK Support
Community Moderator

View solution in original post


All Replies
Solution
Accepted by topic author vivek
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: Add to or create a ContactList or MutableEntityList

There isn't a cast available to convert from a list of contacts to a ContactList, nor would most standard collection types have a ToContactList method unfortunately. Also, because of the type of collection that the contact list is based on, it also doesn't have an add method. 

 

Rather than adding an add method to the ContactList type, it may be preferable to just add another collection type based on List rather than an array, and have a method for this type to convert to ContactList.

Matthew Wood
Act! SDK Support
Community Moderator
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Add to or create a ContactList or MutableEntityList

Cheers for replying Mat I'm relieved I wasn't missing something glaringly obvious!

 

I suppose that would be better idea and would fit within the ContactManager class next to the GetContactAsContactList(Contact) method with something like GetListAsContactList(List<Contact>), or even better upstream to the MutableEntity level.

 

Downer though, I'll have to create the COntactList by doing a lookup of the Contacts I already have, hey ho I suppose it keeps me in a job!

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Silver Super Contributor
Posts: 2,328
Country: USA

Re: Add to or create a ContactList or MutableEntityList

Vivek,

 

I think the way most of us currently do it is by creating an array of contact guids and creating a contact list from that.  I agree that it would be much nicer to be able to simply add or remove a contact from a contact list.  I'm actually surprised that you've been writing addons for this long without needing to do it before.

 

Don't try casting the contact list to something that allows a delete though.  If you do when you delete the contact from the list it deletes it from the database which for obvious reasons is a very unpleasant experience.  Some of us tried that one and had to recover from a backup...

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Add to or create a ContactList or MutableEntityList

Hiya Stan,

 

Yah I was hoping that maybe I was missing a trick. I have to admit it looks like I may have been going around it the wrong way all this time and creating a list from a IContactSource! Hmmm where is the embarassed smiley?!

 

I'm not that keen on casting out since I think I have read about the deletes on the forum in the past by others.

 

Thanks fro the help guys!

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog