Wednesday, April 29, 2015



In the journey of Yammer Integration with SharePoint we have seen so many aspects of Yammer and its options. We have seen to fetch the feeds from yammer, user information, conversations etc. We have touched all options to try those operations in various articles. In my last article related to Yammer I described how to choose a best option while finalizing the Yammer design.

In this article we will see how to display or get Yammer Search results in SharePoint. Earlier Yammer web part was the option to get search results in SharePoint but recently Microsoft has announced the end of support of Yammer web part. So now the available  option is Yammer REST API and we will see it in this article in details.

Following is the REST API to get the search results from the Yammer:


Parameters for this REST are:

Search: search keyword/text

Page: Integer value. Number of page. By default the value is 1. It is helpful when you implement pagination.

Num_per_page: Integer value. This helps to configure number of results per page. 20 maximum.

If everything goes correctly then you will get result in sets: messages, users, topics and groups. You get all related information about conversation like who posted it, at what time, in which group, content, etc.

Following is the sample code to get the search results. In the picture below you can see how the results look like.

Sample code:

yam.platform.request(
   {
   url: "search.json"
   , method: "GET"
   , data: { 'search': self.SearchText() }
   , success: function (msg) {     
$.each(msg.messages.messages, function () {
var summary = this.body.rich;
var path = this.web_url;
alert(summary + "  " + path);
});
});

Result image (json result):




Here a year back I have depicted how one can deeply integrate Yammer search with SharePoint search: SharePoint 2013: Deep integration of Yammer Search with SharePoint search.

Now we will move one step ahead and see how to show SharePoint results and Yammer results together. Yes, this is possible you can implement a custom component which can read data from both SharePoint and Yammer using their respective REST URLs. To learn more about the SharePoint Search REST API click here and here. As shown in below picture this component takes the search keyword/text from the user and sends it to both Yammer REST API and SharePoint REST API, Once it get response from both it shows results combined and ordered on screen/page. Following picture can help to understand the idea.



Let’s take look at each box of this component.

1.   Yammer Search REST API handler :
This handler takes the search text or key word from the JS framework and gives it to the Yammer Search REST service. This service then fetches data from the Yammer network and returns backs to the handler. The search results  are dependent on the current logged in users  access or permission. This REST service returns information of messages, users, topics and groups which is found for that particular keyword or search text. Then the handler creates an array of results and orders it by creation/publishing date and returns it to the Search Results Merger for further processing.
2   
      SharePoint Search REST API handler :
The job of this handler is same as Yammer REST handler, the only difference is it sends the search key/text to the SharePoint Search REST API. The SharePoint Search REST talks with the SharePoint Search service and returns the matched records to the handler. Handler returns the array to the Search Results Merger.
3.   
      Search Result Merger :
The task of merger is two way task. It gets the search key/text from the UI and sends it to the handlers. It also waits for the results from handlers and merge them into one result set and sorts the result by publishing date and binds the result to the UI component. I have used Knock out JS Framework here to do this task as it makes life simpler. You can prefer other frameworks.
4.       
      UI/Screen : This component interacts with the users. It takes the search key/text from the user and shows the search results on the screen.


This way you can integrate Yammer search with SharePoint search. If you want to make the component RWD compliant then it’s cherry on the cake. I will be working to transform this to SharePoint App/ web part, stay tuned!

Happy Yamming!

0 comments:

Post a Comment