07-16-2014 04:40 AM - edited 07-16-2014 04:55 AM
Hi everyone,
Here's an example of doing a contact lookup using multiple criteria.
The sample class attached handles adding a new button to the Contact Detail Toobar which when pressed executes the lookup using the following criteria:
Company - Equal To - Swiftpage - AND
ID/Status - Equal To - Employee - END
The button is added like this:
'Check we're on the detail view If oApp.CurrentViewName = "Act.UI.IContactDetailView" Then 'Add the new button to the toolbar Dim style As CommandBarControl.ItemDisplayStyle = CommandBarControl.ItemDisplayStyle.ImageAndText Dim displayText As String = "Lookup Swiftpage Employees" AddToolbarButton(oApp, "Contact Detail Toolbar", displayText, My.Resources.Resource1.toobarStar, style, New CommandHandler(AddressOf ButtonHandler)) 'redraw the toobars RedrawToolbars(oApp) End If
You'll need the AddToolbarButton and RedrawToobars methods included in the sample class
The lookup is performed like this:
'create relevant criteria columns Dim column1 As CriteriaColumn = oApp.ActFramework.Lookups.GetCriteriaColumn("TBL_CONTACT.COMPANYNAME", True) Dim column2 As CriteriaColumn = oApp.ActFramework.Lookups.GetCriteriaColumn("TBL_CONTACT.CATEGORY", True) 'create intividual criteria items using criteria columns Dim cList = New List(Of Criteria) Dim c1 As Criteria = New Criteria(LogicalOperator.And, 0, 0, column1, OperatorEnum.EqualTo, "Swiftpage") Dim c2 As Criteria = New Criteria(LogicalOperator.End, 0, 0, column2, OperatorEnum.EqualTo, "Employee") cList.Add(c1) cList.Add(c2) 'convert the list to an array Dim cArray As Criteria() = cList.ToArray() 'create a lookup and a contacts list from it. Dim contactLookup As ContactLookup = oApp.ActFramework.Lookups.LookupContactsReplace(cArray, True, True) Dim contactList As ContactList = contactLookup.GetContacts(Nothing) 'apply the current contact list and show in the UI oApp.ApplicationState.SetCurrentContactList(contactList, Nothing) oApp.UIContactManager.ShowListView()
You can download the class at the bottom of this post.
Regards,
Russell
09-06-2019 10:51 AM
Richard, do you know if this code will still work in ACT20.1 or ACT21?