Reply
New Member
thatch
Posts: 31
Country: USA
Message 1 of 13 (5,772 Views)

Retrieving Contacts by Modification Date

Language VB.net

How does one construct a filter to retrieve contacts that have been modified after a specific date?
I've tried all kinds of stuff but have not been successful. Anyway, here's the piece of code that I have
and all I need is the filter criteria construct. Does anyone know how to do this???

Here's the code.

Dim MyFilterCriteria As Act.Framework.IFilterCriteria
Dim cfdModificationDate As ContactFieldDescriptor = ACTFM.Contacts.GetContactFieldDescriptor("TBL_CONTACT.EDIT_DATE", True)
Dim dLastModification as Date

dLastModification = cDate("1/1/2008") ' Let's get any contacts that have been modified after Jan 1, 2008


'
' HOW DOES ONE CONSTRUCT THE FILTER CRITERIA TO RETRIEVE THE CONTACTS????
' The filter criteria for MyFilterCriteria should be defined here.

ACT_Contact_List = ACTFM.Contacts.GetContacts(Nothing, MyFilterCriteria)
Please use plain text.
Copper Contributor
Carlton_Jones
Posts: 98
Country: United States
Message 2 of 13 (5,763 Views)

Re: Retrieving Contacts by Modification Date

Working up an example.
 
However just taking a quick look at your code snippet you need to be using EDITDATE not EDIT_DATE since EDIT_DATE is the alias of the field and EDITDATE is the 'real' name.
Carlton Jones
Sage Software
Please use plain text.
New Member
thatch
Posts: 31
Country: USA
Message 3 of 13 (5,760 Views)

Re: Retrieving Contacts by Modification Date

Thanx Carlton. I'll change the field name to EDITDATE. I just joined this newsgroup and it is really nice to have someone like you answering questions. It makes developing code for ACT! so much enticing and easier for us. It is a win-win situation. Thanx. T
Please use plain text.
Copper Contributor
Carlton_Jones
Posts: 98
Country: United States
Message 4 of 13 (5,740 Views)

Re: Retrieving Contacts by Modification Date

[ Edited ]

T,

 

This should be an example of how this should work.

Let me know if you run into any problems as I am investigating a possible issue with this


try

{

    ContactFieldDescriptor cfd1 = ActFwk.Contacts.GetContactFieldDescriptor("TBL_CONTACT.EDITDATE", true);

    SortCriteria[] sCriteria ={ new SortCriteria(cfd1, ListSortDirection.Descending) };

    ContactList cList;

 

    System.DateTime d1;

    System.DateTime d2;

    d1 = System.DateTime.Parse("01/01/1980");

    d2 = System.DateTime.Parse("12/31/2007");

 

    IFilterCriteria[] oFilterCriteria = { new DateFilterCriteria(cfd1, d1, d2) };

    cList = ActFwk.Contacts.GetContacts(sCriteria, oFilterCriteria);

        ///Continue your code ....

}

catch (Exception ex)

{

    MessageBox.Show(ex.ToString());

}






Message Edited by Carlton_Jones on 03-26-2008 10:51 AM
Carlton Jones
Sage Software
Please use plain text.
Copper Elite Contributor
nbohne
Posts: 95
Country: USA
Message 5 of 13 (5,725 Views)

Re: Retrieving Contacts by Modification Date

Heh, teasing VB developers with C# code, I love it ;-)
Nick Bohne
Effective Solutions, Inc.
Please use plain text.
New Member
thatch
Posts: 31
Country: USA
Message 6 of 13 (5,720 Views)

Re: Retrieving Contacts by Modification Date

Sheraton, Thanx for the code. I'll give it a try. T
Please use plain text.
Copper Contributor
Carlton_Jones
Posts: 98
Country: United States
Message 7 of 13 (5,712 Views)

Re: Retrieving Contacts by Modification Date

[ Edited ]
This better? :smileyhappy:
I make no guarantees on if this will work.
I've used an online C#.NET to VB.NET converter
 
 
Try 
    Dim 
cfd1 As ContactFieldDescriptor ActFwk.Contacts.GetContactFieldDescriptor("TBL_CONTACT.EDITDATE"true)
    
Dim sCriteria() As SortCriteria
    
New SortCriteria(cfd1, ListSortDirection.Descending)
    
    
Dim cList As ContactList
    
Dim d1 As Date
    Dim 
d2 As Date
    
d1 System.DateTime.Parse("01/01/1980")
    d2 
System.DateTime.Parse("12/31/2007")
    MessageBox.Show((cfd1.ColumnName + (
" " + cfd1.Name)))
    
Dim oFilterCriteria() As IFilterCriteria
    
New DateFilterCriteria(cfd1, d1, d2)
    
    cList 
ActFwk.Contacts.GetContacts(sCriteria, oFilterCriteria)
Catch ex As Exception
    
MessageBox.Show(ex.ToString)
End Try


Message Edited by Carlton_Jones on 03-26-2008 01:59 PM
Carlton Jones
Sage Software
Please use plain text.
Copper Elite Contributor
nbohne
Posts: 95
Country: USA
Message 8 of 13 (5,688 Views)

Re: Retrieving Contacts by Modification Date

I only use VB when I have to, which isn't that often, but it looks fine to me =)
Nick Bohne
Effective Solutions, Inc.
Please use plain text.
Astute Commentator
Thatch2
Posts: 135
Country: United States
Message 9 of 13 (2,120 Views)

Re: Retrieving Contacts by Modification Date

I tried numerous instances of this code to no avail. The best I could come up with is:

 

        Dim cfd1 As ContactFieldDescriptor = ACTFM.Contacts.GetContactFieldDescriptor("TBL_CONTACT.EDITDATE", True)

        Dim MyACTGuid As System.Guid
        Dim ACT_Filter_Criteria(1) As Act.Framework.IFilterCriteria
        Dim dStartFilter As Date
        Dim dEndFilter As Date

 

        dStartFilter = System.DateTime.Parse("1/1/1900")
        dEndFilter = System.DateTime.Parse("1/1/2050")

        ACT_Filter_Criteria(0) = New Act.Framework.DateFilterCriteria(cfd1, dStartFilter, dEndFilter)

        MyACTList = ACTFM.Contacts.GetContacts(Nothing, ACT_Filter_Criteria)

 

The code below should return all data that has been modified since 1900 (which is everything in the database. However, it returns 0. Can SOMEONE tell me what is wrong with this code and/or how to make an iFilterCriteria work in VB.Net?

 

Thanx in advance.

 

Tom

Please use plain text.
Moderator
mwood
Posts: 1,161
Country: USA
Message 10 of 13 (2,108 Views)

Re: Retrieving Contacts by Modification Date

Here is another working version in c# -- I figured I'd post this for now, and I should be able to get a translation up here soon but it might take a bit as I don't really use vb

 

ContactFieldDescriptor ContactField = afw.Contacts.GetContactFieldDescriptor("TBL_CONTACT.EDITDATE", Act.Framework.MutableEntities.FieldNameType.Real);
IFilterCriteria[] CriteriaRay = new IFilterCriteria[1];
DateTime StartDate = System.DateTime.Parse("1/1/1900");
DateTime endDate = System.DateTime.Parse("1/1/2050");
CriteriaRay[0] = new Act.Framework.DateFilterCriteria(ContactField, StartDate, endDate);
ContactList cl = afw.Contacts.GetContacts(null, CriteriaRay);

Matthew Wood
Act! SDK Support
Community Moderator
Please use plain text.