AnsweredAssumed Answered

Extending people-finder.js

Question asked by chrisokelly on Jul 11, 2012
Latest reply on Jul 12, 2012 by chrisokelly
Hi Guys,

I am trying to extend people-finder.js to include the telephone number in results. I have made a very basic change to the file as below (changes in bold) (EDIT: turns out I can't bold inside of code tag. Its the userPhoneNumber line at the bottom of the list of variables being var'ed, and the if (userPhoneNumber.length… section at the very bottom.)


         var renderCellDescription = function PeopleFinder_renderCellDescription(elCell, oRecord, oColumn, oData)
         {
            var userName = oRecord.getData("userName"),
               name = userName,
               firstName = oRecord.getData("firstName"),
               lastName = oRecord.getData("lastName"),
               userStatus = oRecord.getData("userStatus"),
               userStatusTime = oRecord.getData("userStatusTime"),
      userPhoneNumber = oRecord.getData("telephone");
            if ((firstName !== undefined) || (lastName !== undefined))
            {
               name = firstName ? firstName + " " : "";
               name += lastName ? lastName : "";
            }
           
            var title = oRecord.getData("jobtitle") || "",
               organization = oRecord.getData("organization") || "";
           
            var desc = '<h3 class="itemname">' + $userProfile(userName, name, 'class="theme-color-1" tabindex="0"') + ' <span class="lighter">(' + $html(userName) + ')</span></h3>';
            if (title.length !== 0)
            {
               if (me.options.viewMode == Alfresco.PeopleFinder.VIEW_MODE_COMPACT)
               {
                  desc += '<div class="detail">' + $html(title) + '</div>';
               }
               else
               {
                  desc += '<div class="detail"><span>' + me.msg("label.title") + ":</span> " + $html(title) + '</div>';
               }
            }
            if (organization.length !== 0)
            {
               if (me.options.viewMode == Alfresco.PeopleFinder.VIEW_MODE_COMPACT)
               {
                  desc += '<div class="detail"> (' + $html(organization) + ')</div>';
               }
               else
               {
                  desc += '<div class="detail"><span>' + me.msg("label.company") + ":</span> " + $html(organization) + '</div>';
               }
            }
            if (userStatus !== null && me.options.viewMode !== Alfresco.PeopleFinder.VIEW_MODE_COMPACT)
            {
               desc += '<div class="user-status">' + $html(userStatus) + ' <span>(' + Alfresco.util.relativeTime(Alfresco.util.fromISO8601(userStatusTime.iso8601)) + ')</span></div>';
            }
       if (userPhoneNumber.length !== 0)
            {
               desc += '<div class="detail"><span>Telephone:</span> ' + $html(userPhoneNumber) + '</div>';
            }
            elCell.innerHTML = desc;
         };

So, what seemed like a very simple change. However, having deployed it I now cannot use people-finder.

What happens is that I can search, it appears to attempt the search but returns no results. I found that if I enter less than 1 character I get the expected "minimum of 1 character(s)" message, and if I type a nonsense string to search for it tells me it received no results. If I make a search that should return results nothing changes.
There is no response in catalina.out or alfresco.log when this happens, which led me to thinking it is an issue with the client side js. Firebug tells me "userPhoneNumber is null".

So obviously there is nothing in the oRecord object called telephone. I can see in Firebug that the JSON response includes a telephone field for each user returned. I looked through people-finder.js for where the oRecord param is passed into PeopleFinder_renderCellDescription however I can't find it called with parameters anywhere.

I am guessing the main issue here is my lack of knowledge of YUI, does anyone know what I should be doing to get the telephone field from the JSON response to the oRecord param?

Outcomes