Community
Showing results for 
Search instead for 
Do you mean 
Reply

Searching upon Phone number or Company name

Tuned Listener
Posts: 29
Country: Canada

Searching upon Phone number or Company name

Hi,
 
 I'm trying to set a lookup for contacts on phone numbers and then in other cases on company name, and I've done that code:
 

Contact cContact = ActApp.ApplicationState.CurrentContact;

cContact.Update();

CriteriaColumn cColumn1;

OperatorEnum oOperator1;

string sValue1 = "some number";

oOperator1 = OperatorEnum.EqualTo;

//Get the column(s) to lookup on

cColumn1 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "USER10", true);

cColumn2 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "COMPANYNAME", true);

cColumn3 = ActFwk.Lookups.GetCriteriaColumn("TBL_ADDRESS", "LINE1", true);

Criteria[] lCriteria = new Criteria[] { new Criteria(LogicalOperator.End, (byte)0, (byte)0, cColumn1, oOperator1, sValue1) };

cLookup = ActFwk.Lookups.LookupContactsReplace(lCriteria, true, true);

//Set our contact list to the lookup

cList = cLookup.GetContacts(null);

ActApp.ApplicationState.SetCurrentContactList(cList, null);

ActApp.UIContactManager.ShowDetailView();

 

 I'm not familiar with criteria column, so I'm not sure if I'm doing the right thing, but if you please try to point out how to get criteria columns.

 

Thank you!

 

Joe

.NET Developer
Copper Contributor
Posts: 98
Country: United States

Re: Searching upon Phone number or Company name

[ Edited ]
Joe,
 
I've responded in an email but I'll go ahead and post part of that here too for everyone's reference.
 
//Example 3
//This example demonstrates how to get and set the value of a contact field.
//Declare our variables.
ContactFieldDescriptor cField;
Contact                cContact;
Object                 oValue;
//Assign the myrecord to our Contact object.
cContact = ActFwk.Contacts.GetMyRecord();
//Get the contact field descriptor for the user 1 field.
cField = ActFwk.Contacts.GetContactFieldDescriptor("Contact.User 1", false);
//etc....

Important to see that you can use the ‘Alias’ for the field.

So while you might not have the exact SQL table name of a field you know what this custom field is called inside the ACT Program.

 

Lets say you’ve created a new field in ACT! called ‘TotalTimeSpent’:

 

If you were to open up the SQL tables you’d be able to see that the Table name of your custom field is CUST_TotalTimeSpent_828761.

If you knew this you could then use cField = ActFwk.Contacts.GetContactFieldDescriptor("TBL_CONTACT.CUST_TotalTimeSpent_828761", true); //True – real name

 

However, you probably only know what you’ve named the field inside the ACT program. Aka ‘TotalTimeSpent’ and thus would use:

cField = ActFwk.Contacts.GetContactFieldDescriptor("Contact.TotalTimeSpent", false); //False - since this is not the field’s real name.
 
Hope this helps,


Message Edited by Carlton_Jones on 03-17-2008 12:16 PM
Carlton Jones
Sage Software
Copper Contributor
Posts: 98
Country: United States

Re: Searching upon Phone number or Company name

[ Edited ]
Additional infomation and greater explaination and detail as well as a list of Contact Fields is available in the Code Samples.chm file included with the SDK download.
 
 
 




Message Edited by Carlton_Jones on 03-17-2008 12:13 PM
Carlton Jones
Sage Software
Tuned Listener
Posts: 29
Country: Canada

Re: Searching upon Phone number or Company name

Thanks Carl,
 
 I've done this now, trying to cover all phone field, but the result is not what I expect, so what's wrong in this?
 

//Perform Lookup

CriteriaColumn cColumn1, cColumn2, cColumn3, cColumn4, cColumn5, cColumn6;

OperatorEnum oOperator1;

string sValue3;

ContactLookup cLookup;

ContactList cList;

//initialize some varables

oOperator1 = OperatorEnum.EqualTo;

sValue3 = textBoxNumber.Text; // =9053322360 (I have lots of contacts with this phone number)

cColumn1 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "MOBILE_PHONE", true);

cColumn2 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "ALTERNATE_PHONE", true);

cColumn3 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "HOME_PHONE", true);

cColumn4 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "FAX_PHONE", true);

cColumn5 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "PAGER_PHONE", true);

cColumn6 = ActFwk.Lookups.GetCriteriaColumn("TBL_CONTACT", "BUSINESS_PHONE", true);

Criteria c1 = new Criteria(LogicalOperator.Or, (byte)0, (byte)0, cColumn1, oOperator1, sValue3);

Criteria c2 = new Criteria(LogicalOperator.Or, (byte)0, (byte)0, cColumn2, oOperator1, sValue3);

Criteria c3 = new Criteria(LogicalOperator.Or, (byte)0, (byte)0, cColumn3, oOperator1, sValue3);

Criteria c4 = new Criteria(LogicalOperator.Or, (byte)0, (byte)0, cColumn4, oOperator1, sValue3);

Criteria c5 = new Criteria(LogicalOperator.Or, (byte)0, (byte)0, cColumn5, oOperator1, sValue3);

Criteria c6 = new Criteria(LogicalOperator.End, (byte)0, (byte)0, cColumn6, oOperator1, sValue3);

Criteria[] lCriteria = new Criteria[] { c1, c2, c3, c4, c5, c6 };

cLookup = ActFwk.Lookups.LookupContactsReplace(lCriteria, true, true);

//Set our contact list to the lookup

cList = cLookup.GetContacts(null);

ActApp.ApplicationState.SetCurrentContactList(cList, null);

ActApp.UIContactManager.ShowDetailView();

 

.NET Developer
Copper Elite Contributor
Posts: 95
Country: USA

Re: Searching upon Phone number or Company name

Is your phone number actually stored without any dashes? Could be the issue
Nick Bohne
Effective Solutions, Inc.
Copper Contributor
Posts: 98
Country: United States

Re: Searching upon Phone number or Company name

What are your results when running this Query (lookup)?
Carlton Jones
Sage Software
Tuned Listener
Posts: 29
Country: Canada

Re: Searching upon Phone number or Company name

Yes they were matches, but I chose to lookup for a number that everyone has it in my contacts, and it returned only one contact, however I was only checking if the code and nothing wrong from ACT point of view, and in that case I need to play around and see what is wrong in my code.
 
 Thanks for the replies.
 
 
Yours,
Joe
.NET Developer
Tuned Listener
Posts: 29
Country: Canada

Re: Searching upon Phone number or Company name

nbohne,
 
 Thanks for the reply, the number is stored in North American format (%%%)%%%-%%%%
 
Do I have to give the exact figure to search?
 
 
Joe
.NET Developer
Tuned Listener
Posts: 29
Country: Canada

Re: Searching upon Phone number or Company name

Is there a possible way from the SDK to return a DataTable from a ContactLookup object or from ContactList? I need to link the search results to a datagrid, and I don't want to iterate through the items.
 
 Thanks again!
 
 
Joe
.NET Developer