我需要根据entity1
的创建更新entity2
(数学计算)
而entity1
的形式是公开的。
当我刷新entity1
表单时,该字段具有旧值,直到我关闭并打开entity1
表单(缓存问题)。
我发现它不会触发Retrieve插件。有没有办法通过刷新表单来克服这个问题?
答案 0 :(得分:0)
首先:最新的CRM有Xrm.Page.data.refresh()
来“自动”更新表单数据(更不用说通过插件更改字段时自动刷新的事实)。
如果升级不是一个选项,我会设置一个“观察者”功能,如下所示:
// attach to Form Load event
function keepYourFieldInSync() {
setInterval(function(){
var current = Xrm.Page.getAttribute("yourField");
// Not shown here, basically get the updated value from server
var fetched = fetch_yourField_value_from_OData_or_SOAP();
if(fetched != current){
Xrm.Page.getAttribute("yourField").setValue(fetched);
// if users aren't allowed to set the field by hand, I'd also include this
// and customize the field to be readonly
Xrm.Page.getAttribute("yourField").setSubmitMode("never");
}
}, 1000); // keep it above 500 to avoid killing the browser
}
我使用这样的“技巧”来识别引号中的状态更改(另一个用户会在此用户处理草稿时激活它)并且它运行良好。