One level up manager and one level down for subordinates in search results?

How do I get one level up with manager and one level down for subordinates in search results?

I found this page which gives only one level up with manager only but I need sub-ordinates too.
Any help is appreciated. Thanks.

Hello, @vijibhas

You can use the following code. As usual, JS methods and events are gotten from this article of documentation. The code works a bit slow so an item that should be hidden pops up for a second.

//When search results are rendered
    function(event, searchResult, itemData){
        //Get current user
        renderer.dataProvider.getCurrentUserAccountName(function (accountName) {
            //Get an object with data of the current user
            renderer.dataProvider.getBoxGroupItemDataById(accountName, function (dataItem) {
                //Change style if it is not the current user or it has not the current user as a manager or it is not the manager of the current user
                if(!(itemData.AccountName == dataItem.Id || itemData.Manager == dataItem.Id || itemData.AccountName == dataItem.ParentId)){
                    searchResult.$elem.css({ 'display': 'none' });

With the code, I tried but I didn't get sub-ordinates for search result.
Attached the image in which I am expecting. Please do help. Thanks.

@e.evseychik Please do help me in resolving this. Thank you.

Hi @vijibhas!
We're currently deciding on the best way to achieve this. I'll get back to you when I have the results.

Please try the following:

// function to expand the items for 2 levels based on condition
function expand(item){
	function (itemData) {
       // check if the box contains the found person or his or her manager
        return itemData.AccountName == item.Properties.Manager || itemData.AccountName == item.Id;       
    }, function () {        

  // when the search result is clicked:
 renderer.searchResultClickedAction = function (itemId) {
    renderer.dataProvider.getBoxGroupItemDataById(itemId, function (item) {
        // drill down to the manager of the found person and call the expand function
        function() {