Community
Showing results for 
Search instead for 
Do you mean 
Reply

What am I missing? Trying to get a simple list of all contacts.

Tuned Listener
Posts: 18
Country: United States

What am I missing? Trying to get a simple list of all contacts.

Here is the test code going to a sample datagrid just to see if I have everything right.

 

//Defines a contact field descriptor for search criteria

ContactFieldDescriptor asdfff = References.ActFrk.Contacts.GetContactFieldDescriptor("TBL_CONTACT.FIRSTNAME", true);

 

//Declare a contact list variable to hold returned list 

ContactList cList;

 

//Declare an array to store all the sorting criteria...just one in this case.

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

 

//Get the contact list into the variable

cList = References.ActFrk.Contacts.GetContacts(sCriteria);

int NumContacts = cList.Count;

 

 

 

//Now we have to pull the contact field to get name??

 for (int i=0; i <= NumContacts; i++)

{

PhoneListForm.cmboContactName_AddItems(
"Yeah Someone here");

}

 

 

This adds the correct number entries but I can't seem to get at the contact name which is what I really want.

cList does not appear to have any way to access it. What am I missing?

 

TIA

JB

Nickel Super Contributor
Posts: 441
Country: UK

Re: What am I missing? Trying to get a simple list of all contacts.

Hope this helps, in vb but should be self explanatory.....

'get the contact name field to sort by Dim cField As Act.Framework.Contacts.ContactFieldDescriptor = ActApp.ActFramework.Contacts.GetContactFieldDescriptor("Contact.Contact", False) 'create the sort criteria (in this case by nae ascending) Dim sCriteria() As Act.Shared.Collections.SortCriteria = {New Act.Shared.Collections.SortCriteria(cField, System.ComponentModel.ListSortDirection.Ascending)} 'get a list of all the contacts and sort it using our criteria Dim cList As Act.Framework.Contacts.ContactList = ActApp.ActFramework.Contacts.GetContacts(sCriteria) 'loop the contacts displaying name and phone number For Each contact As Act.Framework.Contacts.Contact In cList MsgBox(contact.FullName & " " & CStr(contact.Fields("Contact.Phone", False))) Next

 

 

Tom