Skip to Content
-1

How to find who pressed the button

Aug 26, 2017 at 01:05 PM

119

avatar image

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

10 |10000 characters needed characters left characters exceeded

then what's the scenario.....

0

Scenario is, when I try to access the URl and click on button I should able to capture my ID and put it as a text field.

0

who clicked the button? The logged on user. Any action on the view can be used to capture the logged on user by making users access the app from launchp

0

Hi Sharath,

Yes , as who clicked on the button.. Yes they access the application through URL or Launchpad.

Should I try to capture using this ?

0

Then, you can get the logged on user in the launchpad.

Check the link: https://blogs.sap.com/2015/04/06/how-to-get-username-and-other-login-info-in-sap-ui5-application/

0

Why do you capture the username in UI5 app?

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Thomas Arnesen Aug 31, 2017 at 07:46 AM
1

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();
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Aug 31, 2017 at 07:33 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded