Showing posts with label Delve. Show all posts
Showing posts with label Delve. Show all posts

Tuesday 14 June 2016

Retrieve Office 365 Delve Blogs Programmatically using REST API

In this article, you will learn how to get the blogs from Office 365 delve sites on the custom components programmatically using REST API with various filter options.

Query Options :


By default, when user tries to create a blog post from delve user page, the page will be redirected to user's personal site page. All the posts created on delve blog page will be stored in the user’s personal site. i.e., under “/portals/personal/userfirstname/” site.
Some of the queriable fields are content types, file types and file extensions. Only these field values are unique for blogs created on the Office 365 blog site which will not be similar to other items. Some of the unique properties and values are,
  • Content type - The blogs stored on the portal uses story page content type.
  • Secondary File Extensions - The file extension is aspx page but secondary file extension used is PointPub which is unique.
  • File Type - The file type of the blog is PointPub.
We will see how we can query to get the desired results using Search REST API.

Using content type:

First we will find out the content type of story page manually from Office 365 site.
  • From personal site collection, navigate to see all lists folder and then select pages folder. (Or just append “/portals/personal/userfirstname/ppg” to the url and open to see the pages library directly)
  • Go to library settings of Pages library.
  • Click on the Story Page content type. If content types not found, go to advanced settings and allow the content types.
  • From the URL of story page content type, get ctype value. Ctype values shows the content type id of the respective content type. 
Then we need to build the search REST API URL to query the content.

The search REST API using content type will look like below.

Using File Type:

We can also query the blogs using the file type. The file type used for blog is PointPub. The information is stored in JSON format in PointPub files. The file contains the information like Title, SubTitle, Author, Published data, Value, etc. Value contains blog content for each blog.

The search REST API using file type will look like below.

Instead of using file type, you can also use secondary file extension property to filter out the blog data.

We will use Jquery Ajax call to query and get the blog details. In the below code snippet, I have used file type to get all the blog data present on Office 365 site using search API. Similarly other search REST API Url’s can be used to retrieve the blog results.
  1. $.ajax({  
  2.     url: "/_api/search/query?querytext='filetype:PointPub'"// URL can also use content type id to filter the blog data  
  3.     type: "GET",  
  4.     async: false,  
  5.     headers: { "accept""application/json;odata=verbose" },  
  6.     success: function(data){  
  7.         var blogInfo = data.d.query.PrimaryQueryResult.RelevantResults;  
  8.         var blogResults = blogInfo.Table.Rows.results;  
  9.         console.log("Title : "+blogResults[0].Cells.results[3]);  
  10.         console.log("Author : "+blogResults[0].Cells.results[4]);  
  11.     },  
  12.     error: function(data){  
  13.     }  
  14. });  
In the above example, title and author values are retrieved for first blog present in the collection. similarly, other properties or blog content can be retrieved from the collection by changingblogResults[i].Cells.results[j] result set.

Monday 13 June 2016

An Overview of Office 365 Delve Blogs


In this post, you will see about Office 365 Delve Blogs component. The blog feature is supported on Office 365 delve, where users will be able to create or view blogs on the Office 365 portal.


Blog:


Microsoft has introduced new blogs feature on Office 365 delve. Delve creates separate site collection for portals (/portals/hub). It has app pages folder within the site collection which has 2 pages. Here, Point publishing page is present. The delve blogs are stored or can be viewed from point publishing page. Each o365 account will have access to these sites and pages (which is created by default).
At the bottom of delve user page, users will get the blog component.

If users click on all posts link, it will take us to user's blog page where users can add or view their blog posts. Users can create from delve home page or blog page. The following snapshot shows user's blog page.


The saved blogs will immediately start appearing on the blogs page, but not on the delve user page. It will take few minutes of time for published blogs to be available on delve user page. The delay is because of search crawl. The blog posts component on the delve users page is rendered based on the search index. Search should run periodically to get display the blog posts.
Now we will see how we can retrieve the blog posts available on delve user’s page. Users can create new blog by clicking new post tile or by clicking new post from delve user page.

Here, users can put their own data with the existing design. There are multiple options for users to put their content.
  • Images can be added as banner for the blog post.
  • Title or subtitle can be given to the blog post.
  • By clicking the plus icon on the blog content area, Users can put the blog content with text, document links or images, etc.

For inserting blog content, there are many options. Users can insert text with available custom format or can insert the content from the existing portal.

Using Text Section

  • Header – To add header sub title for sections 
  • Text – Paragraph content can be inserted using this component. Within this component, other styling options can also applied. 

  • Bulleted list or Numbered list – To put the content in list format. 
  • Pull Quote – To highlight the paragraph or lines.


Using Content Section

  • Image – Images can be inserted from portal or local drive. 
  • Document – The documents present on the portal using link or directly from one drive. Once inserted, Office Web App preview of the document will be available on the page. The preview page can also be set for document inserted from settings of OWA component.

  • Video – Videos can be inserted from the video portal.
You can insert any element anywhere on the blog to complete it. Then you can save and publish the blog.

Retrieve Delve Boards And Their Documents From Office 365 Using REST API


In this post, you will learn how to retrieve boards and documents (added to board) from Office 365 Delve, using REST API. Jquery Ajax and search APIs are used to perform the operation.


Retrieve Boards:


Board is just a way to categorize the documents on the site. The operation shown below will fetch all the board names that the user has added it to his documents. Say for example, user has added board called “Cricket” to two documents and “Tennis” to one document. This means the user is following two boards. They are Cricket and Tennis (these values will be listed on Delve left pane). There can be boards added by other users as well, which will not be listed on the user's Delve page. We will see how we can retrieve these boards from Office 365 Delve.
  • The search API is used to pull the information. 
  • The necessary parameters to query the board details are the query text and properties. In the query text, we need to pass the path to get the board names available on Delve. We need to set the external content to be true in the properties, so it will retrieve all the properties related to the board.
  • Using Ajax call with get method, retrieve the board names. Set the necessary parameters in the Ajax method.
    1. var getBoardURL = "/_api/search/query?QueryText='Path:\"TAG://PUBLIC/?NAME=*\"'&Properties='IncludeExternalContent:true'";  
    2. $.ajax  
    3. ({  
    4.     url: getBoardURL,  
    5.     method: 'GET',  
    6.     async: false,  
    7.     headers:   
    8.     {  
    9.         "Accept""application/json; odata=verbose"  
    10.     },  
    11.     success: function(response)   
    12.     {  
    13.         // Get the exact result set.    
    14.         var resultSet = response.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;  
    15.         // Loop through result set to get the properties for each boards.    
    16.         for (var i = 0; i < resultSet.length; i++)   
    17.         {  
    18.             console.log("Title    : " + resultSet[i].Cells.results[3].Value);  
    19.             console.log("Actor ID : " + resultSet[i].Cells.results[1].Value);  
    20.         }  
    21.     },  
    22.     error: function(data) {}  
    23. });    
From the response, we can get the board names, their corresponding actor IDs, path and other board details.



Retrieve Documents from board:


  • The board actor ID (identified in the section, above) is used to retrieve the respective board documents. 
  • To retrieve the documents, we will the use search API again to pull the information. 
  • The necessary parameters are the query text and properties. In the query text, pass * or any keyword to retrieve the documents. In the properties parameter, pass the graph query along with actor ID (identified in the section, above) of the board and action ID. (Here, action ID should be 1045 to denote the board). Here, we are passing single board actor ID to retrieve the particular board documents. You can change the logic to get multiple board's documents.
    1. var actorId = ""// Set the actor id of board (can be identified from above section) to see the documents.    
    2. getDocumentURL = "/_api/search/query?QueryText='*'&Properties='GraphQuery:actor(" + actorId + "\\,action\\:1045)'"  
    3. $.ajax  
    4. ({  
    5.     url: getDocumentURL,  
    6.     method: 'GET',  
    7.     async: false,  
    8.     headers:  
    9.     {  
    10.         "Accept""application/json; odata=verbose"  
    11.     },  
    12.     success: function(response)   
    13.     {  
    14.         // Get the exact result set.    
    15.         var resultSet = response.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;  
    16.         // Loop through result set to get the documents from the board.    
    17.         for (var i = 0; i < resultSet.length; i++)   
    18.         {  
    19.             console.log("Title    : " + resultSet[i].Cells.results[3].Value);  
    20.             console.log("URL      : " + resultSet[i].Cells.results[6].Value);  
    21.             // Similarly other values can be retrieved     
    22.         }  
    23.     },  
    24.     error: function(data) {}  
    25. });   
Note: In these cases, you can check the result values in a Browser debugger console. You can change the logic to display the results on the pages. Place these scripts on the page, using the Web parts (Content Editor / Script Editor / any custom Web part). 

Office 365 Delve Features


Delve provides feasibility for users to view their profile information and their items in one place.

Access Delve Site:


  • Login to your Office 365 site.
  • Click the tile present on the left top corner, you can find the set of apps. Find and navigate to the Delve site.

Search:


From the search box, you can search for the documents or the related items. The items are related to the keyword that will be listed on the home page. The items are pulled from the SharePoint site. The items can be the documents, Emails or other user profiles etc.




Profile:



Click “Me” on the left navigation pane and it will show the user profile information on the right side section. You can click edit profile to change your information. The edit page is similar to SharePoint my site user edit page. You can also find your recent documents section under your profile. This section lists down all your recently created or modified documents on the site. On clicking the "See all" option at the right top of the section, you can find all the documents. The documents are sorted and are based on the last modified time value (descending order). You can still filter out the items that are based on the file types.



Documents:



  • For any document, you can mark a document as a favorite document.
  • You can add the document to a board.
  • You can mail the document by using client apps.
  • You can view the permissions for the document.
  • You can find the total views for the document.
  • You can view the document over the Browser, if you click the document preview. Office Web apps feature is used to view it on the Browser. You can edit the document by using edit in the Browser option and then saving it from file tab.



Board:


The way of categorizing the items on the site.
  • You can add any keyword or board (“SharePoint”) to the document.
  • Once saved, you can find your boards on the left side panel of Delve.
  • Also, from the favorite section, you can find the boards that you have added on the site. On the click of any board (“SharePoint”), you can find out all the documents categorized with corresponding keyword.
  • You can mail your board as a link or remove the board totally. The board or a keyword will be removed from all the documents, categorized as “SharePoint”.



Favorites:



Favorites section will list down all your boards or the items that you have marked as favorite. You can still remove any favorite board or document from the favorites list.



People:


People section will list down a few users from the site. You can navigate to their profile to see their personal information or their documents.

Note: Throughout the process, you can see the page name or URL (“http://siteurl/_layouts/15/me.aspx”) will not change, except for editing profile or for any other external action but the query string will keep on changing, based on the actions.