The following example outlines how you can access system information and user information:
var oUser = sap.ui2.shell.getUser(); oUser.load( { depthAtRoot: 2, nodeId: "FOO~Z_ACME_BAR:42", depthAtNode: 1 }, function() { /* success handler: access user data */ }, function(sErrorMessage) { /* failure handler: e.g. display load error */ } );
The load() method that is called on the user object reads data from the back-end system asynchronously. This means that you should process further data in the success handler provided to the load() method.
The JavaScript start-up API logs any errors occuring during load to the browser console. In the failure handler, you may for example display an error message on the screen based on the error message provided.
The user object remains a stub until the load() method has finished with success. You can check whether the object is still a stub using oUser.isStub().
Once the load has been completed successfully, you can access various information related to the user and the logon system. The following list shows the accessor methods available:
// user logon information oUser.getSystem() oUser.getClient() oUser.getId() // user attributes oUser.getFirstName() oUser.getLastName() oUser.getFullName() oUser.getEmail() oUser.getTimeZone() oUser.getWelcomeMessage() // user oUser.getLanguage() oUser.isRtl() oUser.getDateFormat() oUser.getNumberFormat() oUser.getTimeFormat()
For more information, see the JavaScript Docs.