Ensure Office Graph queries respects the HideFromDelve-feature
Office 365 users has for some time now been able to hide items stored in SharePoint Online from Delve, by creating and adding a specific column to the SharePoint library. The column needs to be a option column (Yes/No) and named “HideFromDelve”. Then users needs to mark “Yes” in this column for all the items they don’t want to show up people’s Delve boards. After that the items have been re-indexed by the SharePoint search, they should no longer be visible in Delve but still searchable through SharePoint search.
As with the SharePoint search items hidden from Delve is still picked up by Office Graph, the underlying engine that feeds Delve with data. This is because Delve adds logic to it’s queries against the Office Graph that filters out all the items that have been marked as hidden. This behavior isn’t detailed in the Office Graph documentation since it’s more related to the standard SharePoint search query part rather than the Graph Query Language (GQL) part of the query. Querying the Office Graph is almost as simple as writing a basic SharePoint Search Query.
Below is a standard SharePoint Search Query that I’ve added a GQL parameter to (marked bold). It should retrieve items that the current user either has read or edited recently.
https://[tenant]/_api/search/query?Querytext='*' &Properties='GraphQuery:ACTOR (ME\,OR(action\:1001\,action\:1003))'
While running these types of queries I’ve noticed that I sometimes get items back that I know is hidden from Delve using the method mentioned before. So how do we tackle this? Well, it’s simple, let’s copy what Microsoft does in Delve. By opening up the Delve portal and looking at the network traffic we can see that Microsoft also runs standard queries against the Office Graph, like the one above but with one simple difference, they filter the result by a managed property. From what I can tell, Microsoft now includes this managed property in all SharePoint Online instances.
The following query will return the same result as the previous query with the exception of that it filters out all items that has been marked as to be hidden from Delve.
https://[tenant].sharepoint.com/_api/search/query?Querytext='* AND (NOT HideFromDelve:True)' &Properties='GraphQuery:ACTOR (ME\,OR(action\:1001\,action\:1003))'