Show TOC

Creating, Updating, and Deleting Tiles on the Home PageLocate this document in the navigation structure

The Bookmark service allows you to create, update, and delete tiles on the user's home page.

Creating a Tile
var oBookmarkService = sap.ushell.Container.getService("Bookmark");

oBookmarkService.addBookmark({
  title: "My Bookmark",
  url: "#UI2Fiori2SampleApps-appnavsample",
  icon: "sap-icon://home",
  info: "Any Info",
  subtitle: "Any Subtitle",
  serviceUrl: "/sap/opu/odata/myservice/Object?$count",
  serviceRefreshInterval: 600,
  numberUnit: "Objects"
}).done(function () {
    sap.m.MessageToast.show("Bookmark added");
}).fail(function (sMessage) {
    sap.m.MessageToast.show("Failed to add bookmark: " + sMessage);
});

If a serviceUrl is set, an App Launcher - Dynamic tile is created on the user's home page. Otherwise, an App Launcher - Static tile is created. For more information on tile types, see Configuring Tiles.

Note that the texts in the example above (title, subtitle, and number unit) are not translated.

The URL fragment in the code above is just an example. In your code, you construct the URL from the launchpad. When constructing the URL, make sure to use the external format, for example, a URL generated by the cross-application navigation service. For more information, see Developing Navigation to Another SAP Fiori App.

Checking Whether a Tile Already Exists

The following example shows how to count the number of existing tiles for a given URL on the user's launchpad. This is useful for finding out whether any tile for a given URL already exists on the current user's home.

var oBookmarkService = sap.ushell.Container.getService("Bookmark");

oBookmarkService.countBookmarks("#UI2Fiori2SampleApps-appnavsample").done(function (iCount) {
  sap.m.MessageToast.show("Number of bookmarks: " + iCount);
}).fail(function (sMessage) {
  sap.m.MessageToast.show("Failed to count bookmarks: " + sMessage);
});
Deleting Tiles

The following example shows how to delete all tiles with a given target URL on the user's launchpad:

var oBookmarkService = sap.ushell.Container.getService("Bookmark");

oBookmarkService.deleteBookmarks("#UI2Fiori2SampleApps-appnavsample").done(function (iCount) {
  sap.m.MessageToast.show(iCount + " bookmarks deleted");
}).fail(function (sMessage) {
  sap.m.MessageToast.show("Failed to delete bookmarks: " + sMessage);
}); 
Updating Tiles

The following example shows how to update all existing tiles with a given URL on the user's launchpad:

var oBookmarkService = sap.ushell.Container.getService("Bookmark");
  
oBookmarkService.updateBookmarks("#UI2Fiori2SampleApps-appnavsample", {
  title: "My Bookmark",
  url: "#UI2Fiori2SampleApps-appnavsample",
  icon: "sap-icon://home",
  info: "Any Info",
  subtitle: "Any Subtitle",
  serviceUrl: "/sap/opu/odata/myservice/Object?$count",
  serviceRefreshInterval: 600,
  numberUnit: "Objects"
}).done(function (iCount) {
  sap.m.MessageToast.show(iCount + " bookmarks updated");
}).fail(function (sMessage) {
  sap.m.MessageToast.show("Failed to add bookmark: " + sMessage);
});