![](/img/trans.png)
[英]I want to redirect from one form to another in dynamics 365 crm
[英]How can I prevent a form from saving in Dynamics 365
如果输入的“dni”值已被另一个“人”注册,我想阻止表单保存,我试图阻止表单保存在其 onSave 事件中,然后如果我的条件匹配,我会制作表单然后保存。 所以我做了以下代码:
function saveDni(executionContext) {
try {
const formContext = executionContext.getFormContext();
const currentDni = formContext.getAttribute("cr6ff_dni").getValue();
executionContext.getEventArgs().preventDefault();
var fetchXml = [
"<fetch top='1'>",
" <entity name= 'cr6ff_person'>",
" <filter>",
" <condition attribute='cr6ff_dni' operator='eq' value='", currentDni, "'/>",
" </filter>",
" </entity>",
"</fetch>",
].join("");
fetchXml = "?fetchXml=" + encodeURIComponent(fetchXml);
Xrm.WebApi.retrieveMultipleRecords("cr6ff_person", fetchXml).then(
(result) => {
if (result.entities.length == 0) {
formContext.data.entity.save();
}
}
)
}
catch(error) {
console.log("An error has occurred while validating the user's data.");
}
问题是,当 save() 方法触发时,它也会再次触发这个 function,所以我陷入了一个循环。 关于我如何解决这个问题的任何想法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.