cancel
Showing results for 
Search instead for 
Did you mean: 

Get logged in User details in SAP FIORI app using SAP BAS cloud Foundry

0 Kudos
708

Hello Experts

I Have tried below blog and was successfully able to get the login details.
sap-approuter-user-api-service

The question here is , if i create a simple Custom Fiori application(managed approuter) , how do i get logged in user details in controller.?

Regards

Godson

Accepted Solutions (0)

Answers (2)

Answers (2)

vbalko-claimate
Contributor
0 Kudos

Very same like you described, just make the call

onShowCurrentUser: function() {
    var oModel = new sap.ui.model.odata.v2.ODataModel("/path/to/your/service");
    this.getView().setModel(oModel);


    oModel.read("/CurrentUser", {
        success: function(oData) {
            // Process the response data, e.g., display in a control
            var currentUserDetails = oData.results[0]; // Assuming the first result is the user data
            // Update your view/control with currentUserDetails
        },
        error: function(oError) {
            // Handle errors, e.g., user not logged in or service not reachable
        }
    });
}


junwu
Active Contributor
0 Kudos

in your controller, make a ajax call to get the data.