我正在为Teams建立连接器,并且可以通过调用必要的功能来加载我的自定义配置页面。我的页面上有几个<span>
标签只是为了调试,我正在使用从调用“ getSettings()
”的属性填充这些标签。
<script>
microsoftTeams.initialize();
var teamsSettings = microsoftTeams.settings.getSettings(); //should this not return at least something?
if (teamsSettings == null) {
$(document).ready(function () {
document.getElementById('status').textContent = "Get settings
returned null!"; //i always get null
});
} else {
document.getElementById('entityId').textContent = teamsSettings.entityId;
document.getElementById('configName').textContent = teamsSettings.configName;
document.getElementById('contentUrl').textContent = teamsSettings.contentUrl;
document.getElementById('webhookUrl').textContent = teamsSettings.webhookUrl;
document.getElementById('appType').textContent = teamsSettings.appType;
document.getElementById('userObjectId').textContent = teamsSettings.userObjectId;
}
microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {
saveEvent.notifySuccess();
});
function onClick() {
microsoftTeams.settings.setValidityState(true);
}
</script>
所以我想知道getSettings()
方法是否正在运行,因为我的标签元素为空。在团队中配置连接器时,如何解决JavaScript交互问题?有没有更好的方法来查看通过该方法获得的设置?
答案 0 :(得分:4)
这是使用getSettings()获取webhookUrl的代码段。
microsoftTeams.initialize();
microsoftTeams.settings.getSettings(function (settings) {
document.getElementById('webhookUrl').textContent = settings.webhookUrl;
});