Search for a specific contact by using 'Number2' as search criteria

Hi, 

I'm trying to retreive a contact by using the searchcriteria 'number2' (which is the number on the contact card that's visible to the user). I've tried many different ways of doing this using the Find.svc service, but I can't make it work. 

 

Here is a little example of what I have been doing, anybody have any ideas?

 

public IContact FindContact(string id)
{
var client = new FindClient();
var credentials = new SoCredentials { Ticket = GetTicket() };
var timeZone = new SoTimeZone();
bool succeded;
string providerName = "findcontact";
string storageType = "Criteria";
string[] response;

var restrictions = client.GetAvailableRestrictionColumns(
credentials, ref timeZone, providerName, storageType, out succeded, out response);
if (!succeded)
{
throw new InvalidOperationException(restrictions.Message);
}

string storageKey1 = "number=" + id; //// response[10] + "=" + id;
FindResults findResult;
var findException = client.Find(
credentials, ref timeZone, 1, 2, providerName, storageKey1, storageType, out succeded, out findResult);

if (!succeded)
{
throw new InvalidOperationException(findException.Message);
}

// return contact here...

 

Kind regards Jon

RE: Search for a specific contact by using 'Number2' as search criteria

Hi Jon,

Because FindContact does not expose the number2 field, there are only other ways to query for a contact based on a number2 field.

The first is the most complicated, as it involved writing an archive extender and deploying that on the box where the services reside, or in your application - if you're running in Local mode. Talked about and demoed some code here.

The second is to use the Dynamic (DotSyntax) provider.

using (FindAgent find = new FindAgent())
{
      var archiveColumns = new string[] { "contact.name""contact.department" };
      var restriction = new ArchiveRestrictionInfo[] { 
new ArchiveRestrictionInfo("contact.number2""=""1234567890")
};       FindResults results = find.FindFromRestrictionsColumns(
restriction, 
"Dynamic"
archiveColumns, 
int.MaxValue, 
0); }

Hope this helps.

By: Tony Yates 30 Mar 2012