Xrm.WebApi.retrieveMultipleRecords() 不适用于 htmlweb 资源中的按钮单击

发布于 2025-01-19 10:59:04 字数 1066 浏览 3 评论 0原文

我有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄想挽回 2025-01-26 10:59:04

对该问题的答案是简单的。在按钮的html中添加type =“按钮”

All right answer to that question is simple. add type="button" in html of button

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文