Skip to Content

How to get UserName and other login info in SAP UI5 application

Hi Everyone,

I am writing this blog to get login info into SAP UI5 application, where you can display User ID, FirstName, LastName, FullName, Email etc… in any of your SAP UI5 Apps.

Here is the sample code where you can fetch all the information into JSON format.

//Get User details once logged in

   //Get User details by using srv;

    var y = “/sap/bc/ui2/start_up”;

    var xmlHttp = null;

    xmlHttp = new XMLHttpRequest();

    xmlHttp.onreadystatechange = function() {

    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {

       var oUserData = JSON.parse(xmlHttp.responseText);

          console.log(oUserData);

       }

    };

    xmlHttp.open( “GET”, y, false );

    xmlHttp.send(null);

or we can also use JSON Model

oModel = new sap.ui.model.json.JSONModel();

oModel.loadData(“/sap/bc/ui2/start_up”);


Note: This will only run on SAP UI5 BSP application but not on local SAP UI5 application.

25 Comments
You must be Logged on to comment or reply to a post.