Skip to Content
Author's profile photo Former Member

Get current Theme ID of User in Fiori Launchpad

Hy all,

i had the requirement to find out, which theme the current logged on user has in the fiori launchpad. I’ve searched a little and would like to share the code with u.

1) First Step: Get UserInfo

var UserInfo = sap.ushell.Container.getService(“UserInfo”)

2) Second Step: Get User

var User = UserInfo.getUser();

3) Third Step: Get Them

User.getTheme();

Or in Shortform:

sap.ushell.Container.getService(“UserInfo”).getUser().getTheme();

The 3 Method calls will give you the current Theme ID of the logged on User:

/wp-content/uploads/2016/06/console_sapui5_theme_968448.png

This helped me for my custom development.

I wish you a nice day & thanks for any rewards / feedbacks.

Kind regards,

Michael

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Yogesh Beria
      Yogesh Beria

      The ushell services actually have a lot to offer.

      Its feels like no one really finds it in the documentation to use it where required. Or may be the documentation needs some improvement.

      I recently stumbled upon user Personalization which has helped me enhance my applications.

      Author's profile photo Jacques-Antoine Ollier
      Jacques-Antoine Ollier

      Thank you for this nice piece of info Michael!

      I saw this ushell service in the documentation just before and I could find your blog with the userinfo tag. 🙂

      Do you think this works with the portal service (former HANA Cloud Portal) to retrieve the logged in user info?

      To be noticed, it is SAP Cloud Identity that manages the user in the portal.

      I would need this this info in order to restrict my OData queries, specifically for the lists. I want to filter the list on only the documents corresponding to the logged in user.

      Thank you for your attention.

      Best regards.

      Jacques-Antoine Ollie

      Author's profile photo Sri Divya
      Sri Divya

      Hi Michael, great blog.

      I am new bie to Fiori.

      I have a requirement where I need to change form background to white for blue crystal theme and am able to apply the background when I am loading the application.

      using the following code:

      var UserInfo = sap.ushell.Container.getService("UserInfo");

      var User = UserInfo.getUser();

      var Customtheme = User.getTheme();
      if (Customtheme === “sap_bluecrystal”) {

      that.byId(“sample”).addStyleClass(“printAreaBox”);

      }

      I am need to capture the theme when user has changed the theme on Fiori Launchpad.

      Could you please suggest me on it?

       

      Thank you,

      SriDivyaB.