Reply
Employee
ACTDevNet
Posts: 119
Country: USA
Message 1 of 11 (6,358 Views)

Basic Filter Question

by aweekes1 on 11-26-2007 3:29 AM

Hi,

 As the post title suggests, this is probably a very simple problem but I'm quite new to Act! so I'm struggling a little!

I want to set the parent company based on a custom field, it's simple enough logically to search the relevant field, pull back the company and supply it to the setparent command but I just can;t seem to get my head around how to build a ifiltercriteria in VB.Net.

Has anyone got some sample code laying around that does this?

Appologies for this not being an interesting web plugin question but it would really help me out.

Cheers,

Adam.

Please use plain text.
Employee
ACTDevNet
Posts: 119
Country: USA
Message 2 of 11 (7,592 Views)

Re: Basic Filter Question

by ACTwiz on 11-27-2007 7:52 PM

Im not 100% sure, but I think there is some basic filter code in the SDK documentaion, look thru all of the code stuff, it takes a while to understand where they put stuff. Let me know if that doesn't help.

Jeremy Wesley
ActWiz
Please use plain text.
New Member
everettcomstock
Posts: 19
Country: USA
Message 3 of 11 (7,560 Views)

Re: Basic Filter Question

Hi Everybody,

I wanted to second this request and ask if someone could give a little more insight into implementing a new type that uses the IFilterCriteria interface. I have implemented the IFilterCriteria on a custom type in my app, but I am not getting what I would consider the "expected" results when I execute a method using this custom type.

First and foremost, the GetClause method, what exactly should this method be returning? Should this be a single word to be used as a filter, a string of search terms, a Sql query? I could not find any specific documentation about this method in the SDK, so forgive me if it is listed somewhere else.

Any direction regarding this would be greatly appreciated.

Thanks,
Everett
Please use plain text.
New Member
thatch
Posts: 31
Country: USA
Message 4 of 11 (7,508 Views)

Re: Basic Filter Question

I've looked through the whole documentation in ACT! and I found NOTHING about iFilter or usuable methodologies to use filters in ACT!. If the ACT! SDK people decided to create an incredible cryptic methodology to use filters, they could at least spend some time documenting it. What's wrong with SQL statements to select data?

Please provide this forum with an in-depth description on how to use filters in ACT! to retrieve contacts, activities, etc. by any parameters, whether they be firstname, edit_date, or even create_date.

It is a very important part of database handling, in case you don't know it.

Please......
Please use plain text.
Tuned Listener
rscherrer
Posts: 11
Country: Switzerland
Message 5 of 11 (7,482 Views)

Re: Basic Filter Question

Hi

For building a company/contact/group -list you could use the Lookup functionality
->Act.Framework.Lookups.LookupManager

For looking for activities you will find samples in ACT SDK Samples Reference (ACT!xy_Documented_Code Snippets.chm ->GetTaskListItems() example 3)

If you really would like to use IFilterCriteria based functions you will find a quick and verry dirty solution below . (One of the drawbacks doing it this way could be loosing forward/backward compatibility)



Public Class ContactLIKEFilter
Implements IFilterCriteria

Private SQLClause As String

Public Sub New(ByVal cf As ContactFieldDescriptor, ByVal Argument As String)
SQLClause = "[" & cf.ColumnName & "] LIKE '" & Argument & "%'"
End Sub

Public Function GetClause() As String Implements Act.Framework.IFilterCriteria.GetClause
Return SQLClause
End Function

End Class

Public Class MyQnDSamples
Public Shared Function GetContactFiltered() As ContactList
Dim cfdName As ContactFieldDescriptor = TheACTFWK.Contacts.GetContactFieldDescriptor( _
"TBL_CONTACT.LASTNAME", True)
Dim cSort() As SortCriteria = {New SortCriteria(cfdName, ListSortDirection.Descending)}

Dim CFL As New ContactLIKEFilter(cfdName, "Huffm" )
Dim ifc() As IFilterCriteria = {CFL}

Return TheACTFWK.Contacts.GetContacts(cSort, ifc)
End Function
End Class
Reto Scherrer
Ambit AG
Switzerland
Please use plain text.
New Member
thatch
Posts: 31
Country: USA
Message 6 of 11 (7,474 Views)

Re: Basic Filter Question

Reton, Thanx a lot for your answer. That really makes my life a lot easier. That is a much better way to create filters. Again, thanx. T
Please use plain text.
New Member
rlieving
Posts: 14
Country: United States
Message 7 of 11 (5,684 Views)

Re: Basic Filter Question

I am trying to filter my data before retrieving it to a local list.

 


rscherrer wrote:
HiFor building a company/contact/group -list you could use the Lookup functionality
->Act.Framework.Lookups.LookupManager

How does that work?  The SDK documentation is not clear on this point?  And what is the difference between a filter and a LookupManager? They both require you to understand the table schemas (LookupManager requires CriteriaColumn/late binding to a column name, Filter requires GroupFieldDescriptor/late binding to a column name).   What is the difference?  Why would you say one is better than the other?
I am also having trouble with filters - due to this late binding issue.  Where does one find the name of the tables and columns?  Where is the documentation?  
This next comment is more to the Act SDK developers - what is the wisdom of this late binding architecture?  Why did you mix database fields and objects together?  It makes for a frustrating blend of the worst of both worlds - not quite as good as a database/none of the intellisense of an object.  Am I the only one to notice this?  

 

Please use plain text.
Tuned Listener
rscherrer
Posts: 11
Country: Switzerland
Message 8 of 11 (5,670 Views)

Re: Basic Filter Question

Hi

 

Lookup:

Below you will find a sample for the Lookup functionality

 

Table/column names:

Even in the SDK (2005) was a file ACT! 2005 SDK Sample Code which contains a list of tables and the related columns I get this list out of ACT by using code.

All managers (ContactManager, CompanyManager, ....) do have a member GetFieldDescriptors() which returns an array of DBFieldDescriptor. You can use this as the Datasource property of a a DataGrid(--View). This will display all fields of the current DB (including custom fields and the table holding them-> spillover table)

 

 

Private Function LookupSample() As Act.Framework.Contacts.ContactList

Dim FWK As Act.Framework.ActFramework = ACT_SQL.ACTFramework

Dim SearchCriteria() As Act.Framework.Lookups.Criteria
Dim SortCriteria() As Act.Shared.Collections.SortCriteria

SortCriteria = New Act.Shared.Collections.SortCriteria() { _
New Act.Shared.Collections.SortCriteria( _
FWK.Contacts.GetContactFieldDescriptor("TBL_CONTACT.LASTNAME", True), _
System.ComponentModel.ListSortDirection.Ascending) _
}

Dim colDepartment As Act.Framework.Lookups.CriteriaColumn = _
FWK.Lookups.GetCriteriaColumn("TBL_CONTACT.DEPARTMENT", True)
SearchCriteria = New Act.Framework.Lookups.Criteria() { _
New Act.Framework.Lookups.Criteria(Act.Framework.Lookups.LogicalOperator.End, 0, 0, colDepartment, _
Act.Framework.Lookups.OperatorEnum.ContainsData, _
Act.Framework.Lookups.ValueEnum.Nothing) _
}

Dim lkContacts As Act.Framework.Lookups.ContactLookup = _
FWK.Lookups.LookupContactsReplace(SearchCriteria, True, False)
Dim cList As Act.Framework.Contacts.ContactList = lkContacts.GetContacts(SortCriteria)
Return cList

End Function

 

Reto Scherrer
Ambit AG
Switzerland
Please use plain text.
New Member
rlieving
Posts: 14
Country: United States
Message 9 of 11 (5,602 Views)

Re: Basic Filter Question

[ Edited ]

Thanks rscherrer - I'll give it a try.

 

Does anyone have any less verbose way to write a filter?  The example here seems more than a little extreme in terms of the lines of code.

 

The original example (that uses iFilter) just doesn't work for me.  I keep getting a SQL error, so I might be stuck with the example below.

Message Edited by rlieving on 03-31-2009 12:37 PM
-----
NOTE: Cannot use the example submitted by Reto due to the fact that I don't have the ACT_SQL framework.  As a result I cannot get a Criteria Column.  Anyone else successfully create a filter with a reasonable number of lines of code?
Message Edited by rlieving on 03-31-2009 12:51 PM
Please use plain text.
Tuned Listener
rscherrer
Posts: 11
Country: Switzerland
Message 10 of 11 (5,579 Views)

Re: Basic Filter Question

I'm sorry, I thougt you were familiar with getting an ActFramework instance, so I decided to leave that part as I use it in my framework for ACT.

 

ACT_SQL.ACTFramework is the way I get an instance of ActFramework.

 

If you intend to use the code in a application out of ACT you can get it by

.......

Dim FWK as New ActFramework

FWK.login(.....)

........

 

or if running in a plugin you can get it from the Act.UI.ActApplication parmeter in the OnLoad event whithout the need for login:

 

Overridable Sub OnLoad(ByVal APP As Act.UI.ActApplication) Implements Act.UI.IPlugin.OnLoad

Dim FWK as ActFramework = APP.ActFramework

......

......

End Sub

 

I am sure you will find samples in the SDK which explains that point.

 

IFilter

I do not know if my IFilter-code still works for the current versions of ACT, since I used it in ACT 8/2006. But I will try it again and keep you informed as soon I know more.

 

 

Reto Scherrer
Ambit AG
Switzerland
Please use plain text.