Qlik 感知 - 获取用户应用程序列表并获取当前登录用户



我是Qlik Sense API的用户,我有点沮丧,因为Qlik文档非常混乱。

所以我有三件事需要做。

  1. 获取当前登录的用户。
  2. 获取该用户的应用列表。
  3. 是否有一个页面清楚地列出了可用于函数中传递的 (qlik( arg 的方法?

谢谢

require(['js/qlik'], function (qlik) {
// I need to get the current logged in user from here 
// and also a list of apps this user can view                   
});

更新:

// for getting the user this works like a charm
var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
alert('User:'+reply.qReturn);
});

为了获取应用程序,建议使用以下代码。我不确定它们有何不同。

// This one is what I have found from trying various code snippets found in the documentation.
// This seems to work but there are errors when displaying the apps with the below code snippet.
qlik.getGlobal(self.config).getAppList(function(list) {console.log(list);});
// suggested snippet gives the following errors.
qlik.getAppList(function(list) {console.log(list);});
Error: "WebSocket connection to 'ws://localhost:8000/app/%3Ftransient%3D?reloadUri=http%3A%2F%2Flocalhost%3A8000%2F' failed: Connection closed before receiving a handshake response"
qlik.getGlobal(self.config).getAppList(function(list) {
ia.getList('sheet', function (reply) {
$('#qlik-cont').append('<div id="div-' + key + '"></div>');
var stop = setInterval(function(){
ia.global.getProgress(ia.model.handle).then(function(progress)
{
console.log("DoReload progress", progress);
});
}, 100);
ia.doReload().then(function(result){
if (result) {
ia.getObject('div-' + key, reply.qInfo.qId);
}
else {
console.log('Reload failed');
}
})
.finally(function(){
clearInterval(stop);
});
});
}
});

上面的代码导致以下错误"无效的可视化效果 在服务器上找不到可视化:工作表">

谢谢

要回答您的问题:

1(要获取当前经过身份验证的用户,请使用getAuthenticatedUser,例如:

var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
alert('User:'+reply.qReturn);
});

参考: http://help.qlik.com/en-US/sense-developer/June2017/Subsystems/APIs/Content/CapabilityAPIs/GlobalAPI/getAuthenticatedUser-method.htm

2(要获取应用程序列表,请使用getAppList,例如:

qlik.getAppList(function(list){
var str = "";
list.forEach(function(value) {
str +=  value.qDocName + '('+ value.qDocId +') ';
});
alert(str);
}
};

3( 以下是您可以使用的所有功能的参考: http://help.qlik.com/en-US/sense-developer/June2017/Subsystems/APIs/Content/capability-apis-reference.htm

最新更新