SAP Fiori在UI5应用程序中登录用户详细信息 [英] SAP Fiori Get logged in user details in UI5 application
本文介绍了SAP Fiori在UI5应用程序中登录用户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个SAP Fiori应用程序,我需要获取当前登录的用户详细信息。 我已经在网上搜索了,但找不到解决方案。
是否可以从LaunchPad获取当前登录的用户详细信息。
推荐答案
有一个来自flp shell的UserInfo
服务,可以按如下方式检索:
{ // In Controller
doSomethingUserDetails: async function() {
const oUserInfo = await this.getUserInfoService();
const sUserId = oUserInfo.getId(); // And in SAPUI5 1.86, those became public: .getEmail(), .getFirstName(), .getLastName(), .getFullName(), ...
// ...
},
getUserInfoService: function() {
return new Promise(resolve => sap.ui.require([
"sap/ushell/library"
], oSapUshellLib => {
const oContainer = oSapUshellLib.Container;
const pService = oContainer.getServiceAsync("UserInfo"); // .getService is deprecated!
resolve(pService);
}));
},
}
为与当前最佳实践保持一致,避免直接调用sap.ushell.Container.getService
!
getService
已弃用。请改用getServiceAsync
。- 需要库,而不是如上所述通过全局命名空间(
sap.ushell.*
)引用容器。
或者,也可以通过应用程序路由器从SAP业务技术平台(SAP BTP)公开的user API service检索有关当前用户的信息。
*如果应用部署到旧的Neo环境,请参阅previous edit。
这篇关于SAP Fiori在UI5应用程序中登录用户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文