Skip to Content

How to get the user principle of logged user in UI5?

Feb 26 at 06:20 AM


avatar image

Hi experts,

I have developed a custom standalone UI5 application which will run on HCP (CP/CF).

My Requirement is to get current logged user principle without any java code.

is there any possibility to get user principle in UI5 application.

If yes pls guide me on this issue.

Thanx and Regards


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
zeba parveen Feb 26 at 06:28 AM

Hi Rishabh,

Please use Third party API to get the principal users .


SAP HCP provides a service which can be used to obtain user information as well as log off the user. The details regarding the userapi can be found at

Here’s is the example on how this can be acheived within SAP Web IDE.

Adding the User Details to a View

Add a route into the neo-app.json to reference the userapi

        "path": "/services/userapi",
        "target": {
            "type": "service",
            "name": "userapi"

Create a json model to call the service

var userModel = new sap.ui.model.json.JSONModel("/services/userapi/currentUser");
sap.ui.getCore().setModel(userModel, "userapi");

Now within a view create some fields to display the data returned by the service

<Label text="User Name"></Label>
<Text xmlns="sap.m" text="{userapi>/name}"></Text>
<Label text="First Name"></Label>
<Text xmlns="sap.m" text="{userapi>/firstName}"></Text>
<Label text="Last Name"></Label>
<Text xmlns="sap.m" text="{userapi>/lastName}"></Text>
<Label text="Display Name"></Label>
<Text xmlns="sap.m" text="{userapi>/displayName}"></Text>
<Label text="Email"></Label>
<Text xmlns="sap.m" text="{userapi>/email}"></Text>

10 |10000 characters needed characters left characters exceeded
Hans Raj Feb 26 at 06:38 AM

Hi Rishabh,

try this.

var oUser =;

oUser.load({}, function() {

var userID = oUser.getId();


10 |10000 characters needed characters left characters exceeded