防止在插件中创建 [英] Prevent create in plugin

查看:54
本文介绍了防止在插件中创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在服务活动的预创建上注册的插件。在插件中,我检查了一些条件,如果满足,我想停止创建服务活动。除了创建该服务活动之外,我还想创建另外两个将替换的活动。但是我不希望用户收到所有这些通知。

I have a plugin registered on Pre-Create of a Service Activity. In the plugin I check some conditions and if they are met i want to stop creating the service activity. Instead of that service activity I want to create two other that will be a replacement. But I don't want the user to be notified for all this.

有没有办法停止在CRM 2011上的插件中创建SA记录?

Is there a way to stop the creation of the SA record in a plugin on CRM 2011?

推荐答案

因此,如果用户通过Dynamics CRM GUI触发了服务活动的创建,则通常会保存该表单(通过发送内部 UpdateRequest ),然后通过另一次数据库刷新来刷新。如果您通过插件在两个事件之间删除了记录,则标准消息找不到记录会错误地肯定通知用户。在这种情况下,在插件中引发阻止记录创建的异常等同于会通知用户,但至少他会看到一条可自定义的消息,也许会告诉他为什么保存无效。

So, If a user triggers the creation of the service activity via the Dynamics CRM GUI, the form is normally saved (by sending an internal UpdateRequest), then refreshed via another trip to the database. If you deleted the record in between the two events via a plugin, the user will certainly be notified by the standard "Record can't be found" error message. In this case, throwing an exception in the plugin preventing the creation of the record is equivalent in that the user will be notified, but at least he'd see a customizable message perhaps telling him why the save didn't work.

在我看来,通过插件处理此问题的最佳方法是

It would seem to me the best way to handle this via a plugin is to


  1. 检查您的条件。

  2. 更改(而不是删除)现有的保存服务活动,以匹配您要创建的其他服务活动之一的条件。这样一来,就无需删除任何内容。

  3. 创建其他服务活动。

  4. 使用现在更改的服务活动刷新表单后,您可以执行任何操作您需要使用javascript(打开其他记录,关闭当前记录,等等)。

  1. Check your conditions.
  2. Change (not delete) the existing saving service activity to match the criteria of one of the other service activities you want to create. This way nothing is unnecessarily deleted.
  3. Create the other service activity.
  4. After the form refreshes with the now changed service activity, you can do whatever you want in javascript (open the other record, close the current record, etc.).

如果您可以控制GUI,您可以做一些不同的事情(例如,删除记录发布操作,尽管这仍然会导致一个额外的和不必要的数据库操作),并且您始终可以使用javascript进行客户端验证。

If you have control over the GUI, you can do things a little differently (delete the record post operation, for instance, though this would still result in one additional and unnecessary database operation), and you can always use javascript for client-side validation.

还有一点:我还必须从用户的角度出发,保存一条记录然后又看不到它,这将构成意外的CRM行为。如果发生了这种情况,我至少希望获得有关CRM的这一部分如何工作的培训,或者得到有关实际上发生了根本不同的通知。

One more point: I must also add that from a user's perspective, saving a record and then not seeing it immediately would constitute an unexpected CRM behavior. If something like this happened, I would at least expect to receive either some training on how that section of the CRM works or a notification that something fundamentally different has in fact happened.

这篇关于防止在插件中创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆