Skip to Content
Technical Articles
Author's profile photo Shubham Bathla

Adding Custom Control under ‘App Settings’ of a FIORI/UI5 App

Hi All,

 

Introduction:

Sometimes there are scenarios when you need to provide a feature in your app, which is only relevant for a small set of End-Users of the App.

Also, this feature could be like a one-time configuration or a switch which means the user will not be using it frequently.

Such kind of feature shouldn’t be directly made available to End-Users of the App as it may not be relevant for everyone because of above reasons & also the real estate could be utilized for something important.

Recently I came across such a situation and have used the below approach 🙂

 

Preview:

This%20is%20how%20a%20custom%20control%20in%20App%20Settings%20would%20look%20like

This is how a custom control in App Settings would look like

 

//****——— As a Suggestion by Marian Zeis, Modified on 21/03/2023—————-***//

 

Implementation:

You can use ‘onAfterRendering‘ or ‘onInit‘ method of the controller file of your default view, add the below code

 

onInit: function () {
	var oRenderer = sap.ushell.Container.getRenderer("fiori2"),
                oAddActionButtonProperties = {
                    controlType: "sap.m.Button",
                    oControlProperties: {
                        id: "exampleButton",
                        text: "Blog Example Button",
                        icon: "sap-icon://refresh",
                        press: function () {
                            alert("Example Button was pressed!");
                        }
                    },
                    bIsVisible: true,
                    bCurrentState: true
                };
            oRenderer.addUserAction(oAddActionButtonProperties);
}

 

Result:

Run the App & you should see the button under ‘App Settings’.

Please let me know if you have any suggestions or feedback.

 

Thanks,

Shubham

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Marian Zeis
      Marian Zeis

      Hi Shubham,

      I wanted to achieve the same thing that you have achieved and display a setting fragment.
      Unfortunately, it turns out that you are using a private API here.
      I was therefore recommended the following API:

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

       

      Author's profile photo Shubham Bathla
      Shubham Bathla
      Blog Post Author

      Thanks Marian. Will check this.