Community
Showing results for 
Search instead for 
Do you mean 
Reply

Omit contact in ContactLookup

Tuned Listener
Posts: 19
Country: USA

Omit contact in ContactLookup

I got a ContactLookup from search. Then I need to omit some contacts to create a new ContactLookup. I just need to omit them from the lookup not delete them from the database. ContaList.Remove() and ContactList.RemoveAt() permanently remove the contact from database which is not what I want. Can anyone help?

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Omit contact in ContactLookup


stevewfgmail@yahoo.com wrote:

I got a ContactLookup from search. Then I need to omit some contacts to create a new ContactLookup. I just need to omit them from the lookup not delete them from the database. ContaList.Remove() and ContactList.RemoveAt() permanently remove the contact from database which is not what I want. Can anyone help?


Hi Steve,

 

As far as I'm aware there's no .Omit() method for ContactList.

 

You'd need to create a new ContactList to hold the results, then iterate through your old list and push valid Contacts to the new list.

Then you can then apply the new list as your current lookup.

 

Pseudo code:

ContactList OriginalContactList = // However you get this list here
ContactList NewContactList = new ContactList(); // New list to hold results

// Loop through old list
foreach (Contact c in OriginalContactList)
{
    // Validate contact
    if (c != "Bad Contact")
    {
        // Add to new list
        NewContactList.Add(c);
    }
}

I hope this helps.

 

Sam.

 

 

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Tuned Listener
Posts: 19
Country: USA

Re: Omit contact in ContactLookup

Thanks Sam. That's what I tried to implementing, however 'Add' is not a method of ContactList. Did I miss something?
Nickel Contributor
Posts: 175
Country: USA

Re: Omit contact in ContactLookup

Not knowing how you are getting the ContactList to begin with, is it possible to use the filter criteria to filter the results when initially getting the contacts?
Tuned Listener
Posts: 19
Country: USA

Re: Omit contact in ContactLookup

I use lookup to get the ContactList. Here's how

 

Dim cLookup As ContactLookup
cLookup = HostFramework.Lookups.LookupContactsReplace(lCriteria, True, True)
Dim cList As ContactList
cList = cLookup.GetContacts(Nothing)

Tuned Listener
Posts: 19
Country: USA

Re: Omit contact in ContactLookup

Ok,  after refer to the following thread,

Retrieve and update contact with ContactID

http://community.act.com/t5/Act-Developer-s-Forum/Add-to-or-create-a-ContactList-or-MutableEntityLis...

 

I get the job done by first create an array of GUIDs from ContactList.Item(i).ID, then build my new ContactList using newList=HostFramework.Contacts.GetContactsByID(Nothing, newArray)

 

Thanks for every one's input. This is a great community.

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Omit contact in ContactLookup

Hi Steve,

 

Ah, you beat me to it. My code from yesterday was "brain compiled" and I'd remembered incorrectly that our list had an .Add() method like a normal list.

Upon opening a project this morning to check the code it turns out that the way you're doing it through building a separate GUID list and fetching that back again is the way I handle it too, and therefore, in my humble opinion, the best way ;-)

 

Kind regards,

 

Sam.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Tuned Listener
Posts: 19
Country: USA

Re: Omit contact in ContactLookup

Great to hear that. Thanks Sam. You're very helpful and encouraging.Smiley Happy