Hi all,
I know there are several threads about this, but believe me when I say that I've already tried them, now I'm a little frustrated
Let me explain what I need, we have an application already built, we used javascript on eclipse Luna. One of the last things we need to do, is getting the user name of the currently logged user (just to show it in the view). As I said before, I've tried several possible solutions, but neither of them actually worked, so maybe some of you can give a hand, I bet the problem is some stupid mistake, something I'm missing (honestly I haven't worked with SAP Hana before)
This is one of the examples I tried
But this is the outcome:
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m,sap.makit,sap.viz,sap.ui.commons,sap.ui.table,sap.ushell,sap.ui.layout" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-resourceroots='{ "com.bam":"./", "bam-web":"./bam-web"}' ></script>
console.log("test begin"); oActionsUserButton = new sap.ui.unified.ShellHeadUserItem({ id: "actionsBtn", username: sap.ushell.Container.getService("UserInfo").getId() }); console.log(oActionsUserButton); console.log("END");
Other of the multiples threads I checked was this SAPUI5 - how to get loged User ID?
var oUser = sap.ui2.shell.getUser(); oUser.load({}, function(){ var userID = oUser.getId(); })
But it doesn't work, it only shows the 404 error, because there isn't any error.js, utils.js or startup.js files.
Also
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);
But, it didn't work.
I'm really out of ideas, please help me, any suggestion will be appreciated.