我是Qlik Sense Api的用户,因为Qlik文档非常令人困惑,我有点沮丧。
所以我有三件事我需要做。
谢谢
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);
});
});
}
});
上述代码导致以下错误&#34;无效的可视化 在服务器上找不到可视化:sheet&#34;
谢谢
答案 0 :(得分:2)
回答你的问题:
1)要获取当前经过身份验证的用户,请使用getAuthenticatedUser
,例如:
var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
alert('User:'+reply.qReturn);
});
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