Xrm.WebApi.retrieveMultipleRecords() 不适用于 htmlweb 资源中的按钮单击
我有HTML Webresource和JS文件,可以在弹出窗口中搜索和显示记录。以下代码在页面加载上正常工作,但是xrm.webapi.retrievemultiplerecords()在按钮上无效。请告知什么事。
<div>
<a> Enter Search String </a>
<input type="text" id="searchstring">
<button class="pure-button" onclick="btnClick();">Go</button>
</div>
document.addEventListener('DOMContentLoaded', function () {
// code only gives information if i call btnClick() here
//btnClick();
}
function btnClick() {
Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$top=3").then(
function success(result) {
for (var i = 0; i < result.entities.length; i++) {
console.log(result.entities[i]);
}
// perform additional operations on retrieved records
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}
I have html webresource and js file that searches and shows record in popup. The following code works fine on page load but Xrm.WebApi.retrieveMultipleRecords() would not work on button click. Please advise whats goin on.
<div>
<a> Enter Search String </a>
<input type="text" id="searchstring">
<button class="pure-button" onclick="btnClick();">Go</button>
</div>
document.addEventListener('DOMContentLoaded', function () {
// code only gives information if i call btnClick() here
//btnClick();
}
function btnClick() {
Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$top=3").then(
function success(result) {
for (var i = 0; i < result.entities.length; i++) {
console.log(result.entities[i]);
}
// perform additional operations on retrieved records
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对该问题的答案是简单的。在按钮的html中添加type =“按钮”
All right answer to that question is simple. add type="button" in html of button