Show TOC

Using the Favorites APILocate this document in the navigation structure

Example

The following code sample illustrates how to use the Favorites API to read and display favorites defined by a provider of favorites:

Sample Code
               
EPCM.getSAPTop().LSAPI.getFavoritesPlugin().getFavoritesProviders(getFavPvdrsCB);


function getFavPvdrsCB(favoritesProviders)
{
//This callback function reads the favorites from the first provider of favorites configured in the portal

var favorites = favoritesProviders[0].getFavorites();
        var favMenuItems = [];
                
        for( var i = 0 ; i < favorites.length ; i++ )
        {
                var currFav = favorites[i];
                var itemUrl = currFav.getURL();
                favMenuItems[i] = {
                                title: currFav.getTitle(),
                                click:  navigateToItem(itemUrl, 0),    // 'navigateToItem' is a method which needs to be implemented
                                href: itemUrl,
                                css: ''
                }       
        }
        //Draw a menu and fill it with the 'favMenuItems' array
        //...
}