Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init: function() {
- var oBookmarkService = sap.ushell.Container.getService("Bookmark");
- var sUrl = "/sap/opu/odata/SAP/ZAPP14_SRV_01";
- var oDataModel = new sap.ui.model.odata.v2.ODataModel(sUrl, {
- json: true
- });
- var oFilters = [new sap.ui.model.Filter("roleName", "EQ", "ZDEVELOPER")];
- oDataModel.read('/roleExist', {
- filters: oFilters,
- success: function(oData, response) {
- var oFlpModel = new sap.ui.model.json.JSONModel({});
- oFlpModel.setData(oData.results);
- sap.ui.getCore().setModel(oFlpModel, "oFlpMdl");
- },
- error: function(oError) {}
- });
- oDataModel.attachBatchRequestCompleted(function(oData) {
- var oRole = sap.ui.getCore().getModel("oFlpMdl").getData(oData);
- if (oRole[0].isExists === "X") {
- oBookmarkService.countBookmarks("#ZBOOKMARK-display").done(function(iCount) {
- var oRoleModel2 = new sap.ui.model.json.JSONModel({});
- oRoleModel2.setData(iCount);
- switch (iCount) {
- case (0):
- oBookmarkService.addBookmark({
- title: "Application title",
- url: "#ZBOOKMARK-display",
- icon: "sap-icon://developer-settings",
- info: "Dynamic tile loaded",
- subtitle: oRole[0].roleName
- });
- break;
- case (1):
- return;
- break;
- case (2):
- oBookmarkService.deleteBookmarks("#ZBOOKMARK-display");
- break;
- default:
- return;
- break;
- }
- }).fail(function(sMessage) {
- });
- } else {
- oBookmarkService.deleteBookmarks("#ZBOOKMARK-display");
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement