cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
640
Views
3
Helpful
4
Replies

Search for Contacts / Custom contact properties

bae00000111
Level 1
Level 1

Hello

I need to accomplish hthe following two task, and I'd like to know if they are possible to do with the Jabber Web SDK:

a) Search for contacts by their name or part of it. It should be possible to enter "mil" and get a list of all contacts whose name starts with "mil".

b) Get the phone number of a Jabber contact. The Jabber users in my sandbox CUP server have only very basic properties like 'Department" and "Manager". Is it possible to store additional information such as a phone number for a Jabber contact?

thanks & best regards

Simon

4 Replies 4

jocreed
Cisco Employee
Cisco Employee

Let me look into your questions and see what I can find out.

npetrele
Cisco Employee
Cisco Employee

a) CAXL (the Jabber web SDK) doesn't have a "search for contact by partial name" method, but that should be easy to do in Javascript.  Here's one way of doing it:

var searchstring = "joe";

client.entitySet.each(function(entity) {

     if (entity instanceof jabberwerx.RosterContact) {

          var displayName = entity.getDisplayName();

          if (displayName.indexOf(searchstring) > -1) {

               alert("Found " + searchstring);

          }

     }

}


b) I'm working on that very thing now, so I don't have an answer yet.  It must be possible, but the method to do it with CAXL isn't well documented (read: isn't documented at all as far as I can tell). 



Hey it looks like Nick beat me to it, but Nick is the guy to talk to if you want to use the Jabber SDK for sure.

npetrele
Cisco Employee
Cisco Employee

Sorry, I still haven't figured out how to fetch a vcard or profile with CAXL.  It should be possible doing something like this (this is not even close to working code - it's just a framework that needs working parameters):

// Function to handle response when it's received

var getProfile = function(responseXml) {

     var iq = jabberwerx.Stanza.createWithNode(responseXml);

     if (iq.isError()) {

          console.log("IQ Error");

          var iqError = iq.getErrorInfo();

          console.log("IQ Error " + iqError.type + " " + iqError.text);

     } else {

          console.log("IQ Success");

          console.log(iq);

// extract the info you want

     }

};

// replace the xmlContent with a search that works -- this doesn't

// I've tried it with various searches, including vcard-temp, which

// works with google contacts, but not CIMP or webex connect

// <vCard xmlns='vcard-temp'/> is the one I tried

var xmlContent = "<query xmlns='jabber:iq:search'/>";

client.entitySet.each(function(entity) {

     if (entity instanceof jabberwerx.RosterContact) {

          client.sendIq("get", entity.jid.getBareJID(), xmlContent, getProfile);

     }

});

If you can do something with this, let me know.  In the meantime, I'll keep experimenting and ask the engineers for help.