Skip to Content
-1

How to find who pressed the button

HI ,

I am new to UI5, I have a scenario, where I need to have a button and I need to find who pressed the button or to capture the User ID of the button..

Should I get it through Odata or do I have option here to capture in Java script.

here is the code I have written.

onAssignMe: function(oEvt) {

var oButton = this.getView().byId("userAssign");

//alert("pressed");

},

Thanks
Vijay

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 31, 2017 at 07:46 AM

    I would get it through OData, but if getting it on the client side you could use the below to get the client-side user ID:

    sap.ushell.Container.getService("UserInfo").getId();
    Add comment
    10|10000 characters needed characters exceeded

  • Aug 31, 2017 at 07:33 AM

    Hi Vijay,

    You can use XSJS to get username login on your HANA System.

    Just simple ajax request and it will return your username.

    Please refer to this link -> get current user login

    1. Create XSJS file

    $.response.contentType = 'application/json'; 
    $.response.setBody( $.session.getUsername() );    
    $.response.status = $.net.http.OK;
    

    2. And then at your ui5 app do ajax call to this xsjs.

    3. Please take a look at your console tab on your browser to see return.

    Best Regards,

    Yoppie Ariesthio.

    Add comment
    10|10000 characters needed characters exceeded