我们有时要验证下页面上的一些逻辑,比如开始时间不能晚于结束时间,不对时不让保存。我们可以在相关的字段事件上处理,但这如果要判断的字段比较多时,就比较麻烦了。 这时候我们就可以利用Form的OnSave事件,下面介绍下具体的做法:

1. Form的OnSave事件

Dynamic CRM 2013学习笔记(二十四)页面保存前进行逻辑验证

 

2. JS方法

function formSave(context) {
    if (!dateCheck("new_valid_on", "new_valid_to")) {
        alert("Valid To is earlier than Valid On !");
        context.getEventArgs().preventDefault();
    }
 
    if (!dateCheck("new_valid_from", "new_valid_to")) {
        alert("Valid To is earlier than Valid From !");
        context.getEventArgs().preventDefault();
    }
}

不符合条件时就用这句阻止保存:

context.getEventArgs().preventDefault();

 

是不是很简单,不用为每个相关的字段写一个方法了。

 

 

Dynamic CRM 2013学习笔记 系列汇总 -- 持续更新中

相关文章:

  • 2021-06-24
  • 2021-08-21
  • 2021-10-02
  • 2021-06-12
  • 2021-05-30
  • 2021-10-24
  • 2022-02-24
  • 2022-01-29
猜你喜欢
  • 2021-08-05
  • 2021-06-20
  • 2021-11-08
  • 2021-08-29
  • 2021-08-04
  • 2022-01-15
相关资源
相似解决方案