In your application, you can provide a button or a link that allows users to add a tile
referencing the current application state to the home page of the SAP Fiori launchpad.
Prerequisites
Your application updates the URL hash according to its current state. This ensures that the
tile allows the user to jump directly to the current state or view of the
application.
The application runs in a unified shell environment.
Context
The AddBookmarkButton is part of the sap.ushell
library.
The procedure uses the following services and controls:
Procedure
-
Include the AddBookmarkButton button in a view of your application.
Use the following Code snippet in the view.xml file:
<core:View
xmlns:footerbar="sap.ushell.ui.footerbar"
...
>
...
<footerbar:AddBookmarkButton id="addToHome" />
...
</core:View>
-
During view initialization, predefine the required parameters by setting
appData of the AddBookmarkButton.
The code snippet shows predefined tile parameters:
onInit: function() {
var oView = this.getView(),
oAddToHome = oView.byId("addToHome");
oAddToHome.setAppData({
title: "My Bookmark", // default: ""
subtitle: "(via button)", // default: ""
info: "any info", // default: ""
icon: "sap-icon://home", // default: undefined
numberUnit: "EUR", // default: undefined
serviceUrl: "/any/service/$count", // default: undefined, string or a JS function
serviceRefreshInterval: 100 // default: undefined
customUrl: "http://www.sap.com" // default: undefined, string or a JS function
});
},
-
If a serviceUrl is set either as a string or as a dynamic JavaScript
function, an App Launcher - Dynamic tile is created on the
user's home page. Otherwise, an App Launcher - Static tile is
created. If the application wants to change values before the Save as
Tile dialog is opened, the application can register a
BeforePressHandler.
Update of appData before opening the Save as Tile
dialog:
oView.byId("addToHome").setBeforePressHandler(function () {
oAddToHome.setAppData(oData);
});
-
If a customUrl is set either as a string or a dynamic JS function, it will
be used as the navigation target for the tile that is about to be created.
Next Steps
If the configuration options for the button are not sufficient, for example if you create a
tile referencing a different app, use the Bookmark service API
directly.