Community
Showing results for 
Search instead for 
Do you mean 
Reply

Retrieving a Contact by Email Address using a filter

Astute Commentator
Posts: 168
Country: United States

Retrieving a Contact by Email Address using a filter

HI Folks,

 

I am trying to retrieve a set of contacts that have a matching email i.e. where an email address is equal to say "test@test.com"

 

I am doing this using the ACT! Framework using the code below.

 

              Dim email2desc As Act.Framework.Contacts.ContactFieldDescriptor

             email2desc = ACTFM.Contacts.GetContactFieldDescriptor("TBL_CONTACT.BUSINESS_EMAIL") 

 

             MyACTContactList = ACTFM.Contacts.GetContacts(Nothing, ContactFilter)

However, for the life of me I simply cannot come up with a ContactFilter that will properly match to an Email. Could someone please provide a snipped of code where a user retrieves a contact list using an Email Match.

 

Thanx in advance.

 

T

Copper Super Contributor
Posts: 112
Country: Australia

Re: Retrieving a Contact by Email Address using a filter

sounds like you need to do a "Lookup" which is a query to lookup all contacts that match a pattern.. if you do a search in hee you should find some code to help with that

 

 

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Retrieving a Contact by Email Address using a filter

Hi Thatch,

 

You could have a look at using the Act.Framework.ComparisonFilterCriteria class.

 

With its ctor you could have:

 

ComparisonFilterCriteria(cont1EmailAddyString,ComparisonFilterCriteria.Operation.Equals,cont2EmailAddyString);


HTH

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Astute Commentator
Posts: 168
Country: United States

Re: Retrieving a Contact by Email Address using a filter

VIvek,

 

Thanx for the ComparisonFilterCriteria method. However, I don't see it anywhere on the ACT! Framework. Which library is it in?

 

Thanx.

 

T

Silver Super Contributor
Posts: 2,328
Country: USA

Re: Retrieving a Contact by Email Address using a filter

Thatch,

 

It's in act.framework.

 

act.framework.comparisonfiltercriteria

 

We have all felt your pain.  It takes longer than it should to figure out how to use the various filter criteria methods as well as the sort criteria methods.

 

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: Retrieving a Contact by Email Address using a filter

Hi Thatch,

 

Its a class in the Act.Framework assembly. It has several ctors.

 

using Act.Framework;

ComparisonFilterCriteria oCFC = new ComparisonFilterCriteria(c1EmailString,ComparisonFilterCriteria.Operation.Equals,c2EmailString);

 HTH

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

Re: Retrieving a Contact by Email Address using a filter

Thatch,

 

Now that I've thought about it for a little bit I realized that ozie was right.  You probably don't need to use the comparison filter.  You actually want to do a lookup.  This post should help you get it working.

 

http://community.act.com/t5/Sage-ACT-Developer-s-Forum/Get-Contact-using-Lastname-firstname-as-filte...

 

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!
Astute Commentator
Posts: 168
Country: United States

Re: Retrieving a Contact by Email Address using a filter

Thanx Vivek and Stan.

 

I just found something. The contact filter does NOT work when searching for email addresses!!!!!

It works with other fields like TBL_CONTACT.FIRSTNAME but NOT with TBL_CONTACT.BUSINESS_EMAIL . What am I doing wrong?

 

 

The code that I have is:

                        Dim email2desc As Act.Framework.Contacts.ContactFieldDescriptor

                       Dim ContactFilter() As Act.Framework.IFilterCriteria

                         email2desc = ACTFM.Contacts.GetContactFieldDescriptor("TBL_CONTACT.BUSINESS_EMAIL")
                        ContactFilter = New Act.Framework.IFilterCriteria() {New Act.Framework.ComparisonFilterCriteria(email2desc, ComparisonFilterCriteria.Operation.Equals, "test@test.com")}

                         MyACTContactList = ACTFM.Contacts.GetContacts(MyContactSortCriteria, ContactFilter)

 

When I query the ContactFilter I get:

 

?ContactFilter(0).GetClause
"TBL_CONTACT.BUSINESS_EMAIL = 'test@test.com'"

 

The results I get is 0 i.e. no item found. ONLY on email addresses!

 

I thought that I was going crazy for a while but it appears that searching for an email address does not work in ACT!. Any workarounds?????????????????????????

 

T

Employee
Posts: 1,163
Country: USA

Re: Retrieving a Contact by Email Address using a filter

Doing a lookup here is as Stan and ozie have mentioned going to be the preferable method to get a list of contacts by email. The code above is attempting to compare a string value "test@test.com" to a field descriptor, not it's value. 

 

Below I have a small bit of code that does a lookup by email addresses:

 

MutableEntityFieldDescriptor mefd = (MutableEntityFieldDescriptor)
                       _ActApp.ActFramework.Contacts.GetFieldDescriptor("TBL_CONTACT.BUSINESS_EMAIL");
CriteriaColumn col = _ActApp.ActFramework.Lookups.GetCriteriaColumn(mefd);
Criteria[] criteria = new Criteria[1];
criteria[0] = new Criteria(LogicalOperator.End, 0, 0, col, OperatorEnum.Contains, "test@test.com");
ContactLookup cLookup = _ActApp.ActFramework.Lookups.LookupContactsReplace(criteria, truetrue);
ContactList cl = cLookup.GetContacts(null);
Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Retrieving a Contact by Email Address using a filter

Thanx. That seemed to resolve it.

 

T