javascript - 长时间运行异步更新后关闭 Web 资源

标签 javascript dynamics-crm microsoft-dynamics dynamics-crm-online dynamics-365

我使用 WebAPI 调用一次检索多个 GUID。我遍历每个结果并相应地更新记录。这一切都是异步完成的。我不希望用户等待所有记录更新,只是想关闭网络资源。 我使用 window.close() 但是,它会中断之前启动的异步更新调用。我怎样才能避免这个?以下是我正在调用的电话:

window.opener.Xrm.WebApi.online.retrieveMultipleRecords("new_contract", "?$select=new_contractid&$filter=statecode eq 0 and statuscode eq 100000001&$top=5000")
    .then(function(results) {
        for (var i = 0; i < results.entities.length; i++) {
            var new_contractid = results.entities[i]["new_contractid"];
            var processedGuid = new_contractid.replace(/[{}]/g, "");

            var entity = {};
            entity.new_run = new Date(y).toISOString();

            window.opener.Xrm.WebApi.online.updateRecord("new_contract", processedGuid, entity)
                .then(function success(result) {
                    var updatedEntityId = result.id;
                },
                function (error) {
                    Xrm.Utility.alertDialog(error.message);
                });
        }
    }, function (error) {
        Xrm.Utility.alertDialog(error.message);
    });

我正在考虑改用后端的插件。我不确定采用哪种方法,任何输入都会很棒!!

最佳答案

我建议您使用“自定义操作”来实现它,即触发即忘。将所有逻辑移到那里。

It seems we should be thinking of the custom actions as of the “functions”. Those functions can be defined as a mix of workflow steps and plugins – we can pass input parameters into the custom action and retrieve output parameters from the custom action. The reason we can call then “functions” is that, unlike with the workflow/plugins, we can, actually, call those functions from other places – we can call them from javascripts, we can call them from workflows, and we can call them from plugins.

Read more

关于javascript - 长时间运行异步更新后关闭 Web 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54080977/

相关文章:

javascript - Blogger 代码数据 :post. url 用作带有图像按钮的可点击链接

使用 || 的 javascript 变量初始化和 {}

javascript - ES6 生成器 : transforming callbacks to iterators

javascript - 如何在React Native中设置键盘上方的TextInput

c# - 从 MS CRM 插件(沙盒)向 Azure 服务总线发送自定义消息

javascript - 在 Dynamics 365 CRM 统一接口(interface)中重新加载/刷新子网格时重新加载表单

dynamics-crm-2011 - 我们可以在 ms 2016 中增加内联查找字段中 10 条记录的计数吗

dynamics-crm - Dynamics 365 拖放附件

c# - 在输出参数 CRM 中返回 EntityCollection 时出错

visual-studio-2013 - 远程调试Axe 2012 IL代码