gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 16:32:21 25 4
gpt4 key购买 nike

我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com