Community
Showing results for 
Search instead for 
Do you mean 
Reply

How to Filter Contactlist on Startup ACT

Accepted Solution Solved
New Member
Posts: 7
Country: Germany
Accepted Solution

How to Filter Contactlist on Startup ACT

[ Edited ]

Hi.

 

as configured we start ACT to show the Contact List. OK It will show all Contacts.

But we want now to show only the associated Contacts for the current user.

 

Each contact has an additional field for the associated user.

On my try's i can use lookup to filter the Contact List but never can show the filtered Contacts on the current Contact List View.

Any proposals ?

 

Regards Dirk


Accepted Solutions
Solution
Accepted by topic author Dirk
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: How to Filter Contactlist on Startup ACT

You need to call ActApp.ApplicationState.SetCurrentContactList(ContactList contactlist, IContactSource currentContactQuery), the first parameter should be pretty straightforward, Lookups.LookupContacts(ContactList contactList) will return IContactSource.

Matthew Wood
Act! SDK Support
Community Moderator

View solution in original post


All Replies
Employee
Posts: 1,163
Country: USA

Re: How to Filter Contactlist on Startup ACT

I have two different ideas about why it may not be working for you but to sort that out I need to ask a couple questions. First, when are you setting the current lookup and second how are you doing it.

 

If it's the latter, the method we should be using is ActFramework.Lookups.LookupContactsNarrow(), since the initial lookup is all contacts. For the latter I believe the absolute earliest this could be done would be after ViewLoaded.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 7
Country: Germany

Re: How to Filter Contactlist on Startup ACT

Hi Matthew,

i tried in that way.

For this try i made a MenuEntry to start the Code.

 

        Dim cSort As Act.Framework.Lookups.CriteriaColumn
        Dim oOperator As Act.Framework.Lookups.OperatorEnum = Act.Framework.Lookups.OperatorEnum.EqualTo
        Dim iCriteria() As Act.Framework.Lookups.Criteria
        cSort = ACTFwk.Lookups.GetCriteriaColumn("TBL_CONTACT.CUST_Betreuer_053242525", True)
        iCriteria = New Act.Framework.Lookups.Criteria() {New Act.Framework.Lookups.Criteria(Act.Framework.Lookups.LogicalOperator.End, CType(0, Byte), CType(0, Byte), cSort, oOperator, "Wittrin")}

        ACTFwk.Lookups.LookupContactsReplace(iCriteria, True, True)

        ACTApp.CurrentView.RefreshView()

 

I had a short look into LookupContactsNarrow() but can't find out the correct way to use it.

 

LookupContactsNarrow(Criteria() as act.framwork.looups.criteria, LookupToNarrow as act.framework.lookups.contactlookup)

 

- Criteria i guess the same a i use it in my test

- LookUpNarrow ???? how to set the Contaktlookup

 

Regards Dirk

 

 

 

        Dim cSort As Act.Framework.Lookups.CriteriaColumn
        Dim oOperator As Act.Framework.Lookups.OperatorEnum = Act.Framework.Lookups.OperatorEnum.EqualTo
        Dim iCriteria() As Act.Framework.Lookups.Criteria
        cSort = ACTFwk.Lookups.GetCriteriaColumn("TBL_CONTACT.CUST_Betreuer_053242525", True)
        iCriteria = New Act.Framework.Lookups.Criteria() {New Act.Framework.Lookups.Criteria(Act.Framework.Lookups.LogicalOperator.End, CType(0, Byte), CType(0, Byte), cSort, oOperator, "Wittrin")}

        ACTFwk.Lookups.LookupContactsReplace(iCriteria, True, True)

        ACTApp.CurrentView.RefreshView()

Employee
Posts: 1,163
Country: USA

Re: How to Filter Contactlist on Startup ACT

For your scenario, there's no reason you can't use LookupContactsReplace(), the ContactLookup it's looking for would be the current one, or if you were refining a search it could be one that you'd used previously. There is also a couple of overloads that do not need a ContactLookup

 

Is this code that you're currently using not working? I'm comparing it to a few samples that I have and it looks very similar.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 7
Country: Germany

Re: How to Filter Contactlist on Startup ACT

Hi Matthew,

the Code is working i can access the filtered Lookup in my Prog. But the filtered Lookup isn't shown as ContactList on the Screen.

 

Regards Dirk

 

Solution
Accepted by topic author Dirk
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: How to Filter Contactlist on Startup ACT

You need to call ActApp.ApplicationState.SetCurrentContactList(ContactList contactlist, IContactSource currentContactQuery), the first parameter should be pretty straightforward, Lookups.LookupContacts(ContactList contactList) will return IContactSource.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 7
Country: Germany

Re: How to Filter Contactlist on Startup ACT

Hi Matthew,

thanks for advise. With the last hint it works now.

Here my code snip.

 

       Dim cSort As Act.Framework.Lookups.CriteriaColumn
        Dim oOperator As Act.Framework.Lookups.OperatorEnum = Act.Framework.Lookups.OperatorEnum.EqualTo
        Dim iCriteria() As Act.Framework.Lookups.Criteria
        cSort = ACTFwk.Lookups.GetCriteriaColumn("TBL_CONTACT.CUST_Betreuer_053242525", True)
        iCriteria = New Act.Framework.Lookups.Criteria() {New Act.Framework.Lookups.Criteria(Act.Framework.Lookups.LogicalOperator.End, CType(0, Byte), CType(0, Byte), cSort, oOperator, "Wittrin")}


        cl = ACTFwk.Lookups.LookupContactsReplace(iCriteria, True, True).GetContacts(Nothing)
        ics = ACTFwk.Lookups.LookupContacts(cl)

        ACTApp.ApplicationState.SetCurrentContactList(cl, ics)

 

Regards Dirk

Bronze Super Contributor
Posts: 1,234
Country: USA

Re: How to Filter Contactlist on Startup ACT

[ Edited ]

Different way to do the same thing. Use a saved criteria (*.QRY)  instead of building it up in code.
This way you can change the criteria at any time.

 

DIm cFilename as string = Me.HostFramework.SupplementalFileManager.Workgroup.Path.ToString() + "\Queries\Startup.qry"
Using CriteriaStream As FileStream = New FileStream(cFilename, FileMode.Open) Me.HostApplication.UILookupManager.LookupContact(Me.HostFramework.Lookups.LoadLookupCriteria(CriteriaStream)) End Using

 

-- Jim Durkin

Bronze Super Contributor
Posts: 1,234
Country: USA

Re: How to Filter Contactlist on Startup ACT

[ Edited ]

I actually just played with the code i posted in the previous post. It brings forward the "Replace, append, Narrow" dialog box which is not a desired effect on startup.

 

Here is the reworked code which won't bring forward that dialog box.

 

 Dim cFilename As String = Me.HostFramework.SupplementalFileManager.Workgroup.Path.ToString() + "\Queries\Startup.QRY"
                If IO.File.Exists(cFilename) Then
                    Using CriteriaStream As IO.FileStream = New IO.FileStream(cFilename, IO.FileMode.Open)
                        Dim cContactList As Act.Framework.Contacts.ContactList = Nothing
                        cContactList = Me.HostFramework.Lookups.LookupContactsReplace(Me.HostFramework.Lookups.LoadLookupCriteria(CriteriaStream), True, True).GetContacts(Nothing)
                        Me.HostApplication.ApplicationState.SetCurrentContactList(cContactList, Me.HostFramework.Lookups.LookupContacts(cContactList))
                    End Using
                End If

 

-- Jim Durkin

New Member
Posts: 7
Country: Germany

Re: How to Filter Contactlist on Startup ACT

Hi Jim,

nice approach.

Could you please post how the Startup.qry has to look like

 

Some changes I had to made in my Code above.

- Filter the List only for our Sales People.

For it I used current LogonUser with "CurrentUser.LastName" instead of "Wittrin"

 

 

 

Regards Dirk