I'm developing a IBM Content Navigator plugin, which allows me to open a selected folder from the search feature in the browse feature. The plugin action contains the following code:
// Variable contentItem is provided by Content Navigator when executing the plugin action.
let layout = ecm.model.desktop.layoutDijit;
let browsePaneMenuItem = layout.launchBarContainer.getMenuItemByID("browsePane");
layout.launchBarContainer._menuItemClick(browsePaneMenuItem, false);
layout.mainPane = layout.launchBarContainer._panels["browsePane"];
layout.mainPane.folderTree._tree._selectItem(contentItem);
This code switches the feature and opens the content of the selected folder (contentItem
) as the result set in the center panel. However, the folder tree does not open the item at the specific location. To do that, I've tried the following code:
let repo = layout.mainPane.repository;
let parentItemDocId = contentItem.attributes.Parent;
let parentItemTemplate = parentItemDocId.split(',')[0] || null;
repo.retrieveItem(parentItemDocId, function(item) {
contentItem.parent = item;
layout.mainPane.folderTree._tree._selectItem(item);
console.debug('parents parent: ' + item.parent);
}, parentItemTemplate, "current", null, contentItem.objectStoreId, "", null);
The item.parent
property in console.debug
is undefined
, when I call retrieveItem
on the repository object.
The contentItem.parent
property points to the search, in which the item is being shown. However, contentItem.attributes.Parent
is the docid of the actual parent folder. I suspect, Content Navigator can't open the folder, because the contentItem
's parent is not the same item in search feature as in the browse feature.
How can I open the specific folder in the folder tree?
To open a specific folder on a Folder Tree all you need to do is create an array of ids with the path of the folders from the root folder to the folder you want to open (you can see the Dossier example in the redbooks to see how to loop subfolders on the server side). Then run the below js code, when path is an array of objects with id: (starting with the root folder and ending with the selected folder)