Community
Showing results for 
Search instead for 
Do you mean 
Reply

StaticTextFilterCriteria Example

Nickel Contributor
Posts: 175
Country: USA

StaticTextFilterCriteria Example

[ Edited ]

Since I found very little info on the StaticTextFilterCriteria when searching earlier, I figured I'd post this to help out anyone else who may end up looking.

 

Dim hisFilter As Act.Framework.IFilterCriteria = New Act.Framework.StaticTextFilterCriteria("Regarding NOT LIKE 'Swiftpage e-mail%' AND Regarding NOT LIKE 'Swiftpage Drip%'")
        Dim crit As New List(Of Act.Framework.IFilterCriteria) From {hisFilter
        For Each con As Act.Framework.Contacts.Contact In conList
            Dim hisList As Act.Framework.Histories.HistoryList
            hisList = actf.Histories.GetHistories(Nothing, con, crit.ToArray)
            For Each his As Act.Framework.Histories.History In hisList
                '...

Basically, you can use the StaticTextFilterCriteria as if it was a WHERE clause in a SQL statement. In the sample above, I'm using two LIKE statements with wildcards, so I think that is pretty definitive that raw SQL works. Also, "Regarding" is the actual name of the field (i.e. FieldDescriptor.Name).

 

 

Edit: Code didn't show up well. Had to remove a close brace (can't type it because it ends the post) from the 2nd line of the code as it prematurely ended the code block. Hopefully someone can take a look at that.

Copper Elite Contributor
Posts: 82
Country: Canada

Re: StaticTextFilterCriteria Example

[ Edited ]

In my testing, this doesn't seem to work with custom tables. Neither does implementing my own IFilterCriteria class. I tried to create a simple "Equals" filter and it always returned all records in the table no matter what I did. It seems that the GetClause method never gets called. Has anyone else had similar experience? 

 

 

Ahsan Khalid

Chief Technology Officer
Keystroke Quality Computing Inc.
www.keystroke.ca

Nickel Contributor
Posts: 175
Country: USA

Re: StaticTextFilterCriteria Example

Just a thought, but you might have to put the full name of the field (TableName.FieldName) in the clause. Mine worked probably because I was only dealing with one, known table, History.
Copper Elite Contributor
Posts: 82
Country: Canada

Re: StaticTextFilterCriteria Example

[ Edited ]

Yes, that is what I have been using as well as just the field name.

 

I also created a simple ComparisonFilterCriteria, and used the GetClause method to get the clause and used that clause to create a StaticTextFilterCriteria as well as my own custom criteria. In theory, this should have worked. It does work for Contacts, but not for Custom tables, which leads me to believe that this is some sort of bug.

 

Edit: Found an old thread where someone else was having a similar issue with creating custom IFilterCriteria filters for custom tables: http://community.act.com/t5/Act-Developer-s-Forum/Using-IFilterCriteria-with-SubEntities/td-p/40601

Ahsan Khalid

Chief Technology Officer
Keystroke Quality Computing Inc.
www.keystroke.ca