Community
Showing results for 
Search instead for 
Do you mean 
Reply

Can't find a Contact by a user field

Copper Contributor
Posts: 21
Country: United Kingdom

Can't find a Contact by a user field

I need to find a number of Contacts based upon a filter as here: -

 

                Field = ActFramework.Contacts.GetContactFieldDescriptor("My_Field", FieldNameType.Alias)
                Filter = New ComparisonFilterCriteria() {New ComparisonFilterCriteria(Field, Act.Framework.ComparisonFilterCriteria.Operation.Equals, "ABC123")}
                ContactList = ActFramework.Contacts.GetContacts(Nothing, Filter)

"Field" and "FIlter" appear to be correct but this always returns zero records. Any ideas?

 

Thanks.

Luke

 

Nickel Contributor
Posts: 175
Country: USA

Re: Can't find a Contact by a user field

Instead of using the ContactFieldDescriptor, try using the MutableEntityFieldDescriptor. The MutatableEntity one is a lower level class and tends not to be as buggy.

Copper Contributor
Posts: 21
Country: United Kingdom

Re: Can't find a Contact by a user field

Thanks for you suggestion Knif.

 

I've tried that but no luck I'm afraid.

 

Strangely, the same code filters correctly when run against the Company table but not with Contacts.

 

In order to work around this I've had to use more of a brute-force approach to finding the right records. This isn't ideal and I'm a bit concerned that something so simple doesn't work! 

 

 

 

Nickel Contributor
Posts: 175
Country: USA

Re: Can't find a Contact by a user field

[ Edited ]

That's understandable. The issue I had was I got the correct number of items returned, but each item only consisted of null values. I switched to the MutableEntityFieldDescriptor and then I got the actual values. There are a lot of little bugs like that in the old SDK/API, when Sage owned ACT!

 

Edit:

Just a little bit more info. I checked through what code I had sitting around. I didn't find anything dealing with the contacts, but I did have some with other things like Companies and Opportunities. I noticed a slight difference in mine versus yours. A copy of mine is below.

 Dim od As Act.Framework.MutableEntities.MutableEntityFieldDescriptor = actf.Opportunities.GetMutableEntityFieldDescriptor("TBL_OPPORTUNITY.USER1", Act.Framework.MutableEntities.FieldNameType.Real)
                Dim filter As New Act.Framework.ComparisonFilterCriteria(od, Act.Framework.ComparisonFilterCriteria.Operation.Equals, dr("ProposalNumber"))
                Dim opList As Act.Framework.Opportunities.OpportunityList = actf.Opportunities.GetOpportunities(Nothing, New Act.Framework.IFilterCriteria() {filter})

I'm creating a new list of IFilterCriteria instead of using the ComparisonFilterCriteria. No idea if that change would work. I'd say it falls into the "can't hurt to try" category.

 

Copper Contributor
Posts: 21
Country: United Kingdom

Re: Can't find a Contact by a user field

[ Edited ]

Thanks again Knif.

I've tried that and still no luck. Both that method and others always return an apparently valid descriptor. None of them ever return records when the filter is applied though.

I'm (vaguely) aware that ACT! uses overflow tables and what we see as a single table via the SDK may be multiple tables internally. I'm wondering if this issue has something to do with that. I can't believe that basic contacts filtering has never worked in ACT!

Anyone from Swiftpage care to comment?