CRM Form 取消 OnSave 事件

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 10:18   154   0

在Javascript里,我们取消一个事件可以用 window.event.returnValue来解决。

比如点击一个链接 <a .... /> ,我们可以为这个链接增加一个 onclick 的事件处理,并在处理中加上 window.event.returnValue = false , 这样该链接就不会把我们跳转到另一个制定的 URL 了。

在CRM 4 里,我们也有类似的处理方法。在一个 Form 的 OnSave 处理里,我们可以用 event.returnValue = false, 来取消保存。

在CRM 2011 里,取消 Form 的 OnSave 就要更复杂了。

首先要在添加 OnSave的处理函数时选中 “Pass execution context as first parameter”

然后在你定义的函数中,首先要有一个关于context的ExecutionObj参数,然后可以使用ExecutionObj.getEventArgs().preventDefault()

function OnSaveHandler(ExecutionObj){
     //Place all your data validation here
     //In case data is not valid call the below method
     // The getEventArgs() method returns an object with methods to manage the Save event.
     // The preventDefault() method cancels the save operation
     ExecutionObj.getEventArgs().preventDefault();
}

具体也可以参见 CRM 2011 SDK "Save Event Arguments Reference" 一节。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP