Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
frank_xie
Advisor
Advisor
For some reason, we need to extend the user setting in Fiori Launchpad to add specific buttons or other actions to fulfill the customer requirement.


Before we do that, we need to understand the certain area for the user setting.

User Preferences dialog box:

https://sapui5.hana.ondemand.com/sdk/#/api/sap.ushell.renderers.fiori2.Renderer%23methods/addUserPre...


User Actions Menu:

https://sapui5.hana.ondemand.com/sdk/#/api/sap.ushell.renderers.fiori2.Renderer%23methods/showAction...



Example code:

You can add the code snippet in your component.js "init" function to see the behavior:
var oRenderer = sap.ushell.Container.getRenderer("fiori2");
var oEntry2 = {
title: "title2",
value: function () {
return jQuery.Deferred().resolve("entryTitleToBeDisplayed2");
},
content: function () {
var deferred = jQuery.Deferred();
//deferred.resolve(new sap.m.CheckBox({ text: "Button", selected: true }));
return jQuery.Deferred().resolve(new sap.m.CheckBox({
text: "Option", selected: bOptionStatus, select: function () {}
}));
},
onSave: function () {
return jQuery.Deferred().resolve();
}
};
oRenderer.addUserPreferencesEntry(oEntry2);

var handlePress = function (e) {
var oDialog = new sap.m.Dialog({
content: [new sap.m.CheckBox({
text: "Option",
selected: bOptionStatus
})],
endButton: new sap.m.Button({
text: "Close",
press: function (e) {
e.getSource().getParent().close();
}.bind(this)
})
});
oDialog.open();
}

var button1 = new sap.m.Button({ text: "testmybutton", press: handlePress });
oRenderer.showActionButton([button1.getId()], false, ["home", "app"]);

User Actions Menu:


If you click the button, there will be a dialog.


User Preferences dialog box:


Additional: There is a statement JQuery.deferred(), you can ref to the link. Personally, I think there isn't need to use the complex code, since the character isn't used here, the below codes should also work:
value: "entryTitleToBeDisplayed2",
content: { new sap.m.CheckBox({ text: "Option", selected: bOptionStatus, select: function () {} })},

Another big problem is how to persist the data in your extended user setting, you can ref to the blog.