当字段中的数据无效时,我会设置字段级通知。然后,我将数据更改为有效的数据,但由于我已将通知设置为onSave,因此不会触发。
function ValidateFields(executionContext) {
console.log("Init");
var formContext = executionContext.getFormContext();
var bfenummer_value = formContext.getAttribute("kk_ejerlav").getValue();
var bfenummer_control = formContext.getControl("kk_ejerlav");
var bfenummer_uniqueid = "bfenummer";
if(!isNumeric(bfenummer_value))
{
bfenummer_control.setNotification("Angiv et tal mellem -2147483648 og 2147483647", bfenummer_uniqueid);
console.log("Set " + isNumeric(bfenummer_value));
// setTimeout(function () {
// bfenummer_control.clearNotification(bfenummer_uniqueid);
// console.log("Clear " + isNumeric(bfenummer_value));
// }, 1000);
}
else {
bfenummer_control.clearNotification(bfenummer_uniqueid);
console.log("Clear " + isNumeric(bfenummer_value));
}
}
function isNumeric(value) {
return /^-?d+$/.test(value);
}
您需要在OnChange事件上为"kk_ejerlav";字段
类似这样的东西:
function ejerlavChanged(executionContext){
var formContext = executionContext.getFormContext();
var bfenummer_value = formContext.getAttribute("kk_ejerlav").getValue();
var bfenummer_control = formContext.getControl("kk_ejerlav");
var bfenummer_uniqueid = "bfenummer";
if(isNumeric(bfenummer_value)){
bfenummer_control.clearNotification(bfenummer_uniqueid);
console.log("Clear " + isNumeric(bfenummer_value));
}
}
function isNumeric(value) {
return /^-?d+$/.test(value);
}