Skip to Content

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

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


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 26, 2018 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>
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 26, 2018 at 06:38 AM

    Hi Rishabh,

    try this.

    var oUser =;

    oUser.load({}, function() {

    var userID = oUser.getId();


    Add comment
    10|10000 characters needed characters exceeded

  • Jun 24, 2018 at 05:56 AM

    Hello Rishabh,

    Are you able to use the same "userapi" service for the projects which will run on CP and CF?

    I have used this service in a project and deployed the same in CF, but it fails to get data.

    Add comment
    10|10000 characters needed characters exceeded