Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>