crm 2011更新在后同步和后异步阶段触发插件的记录 [英] crm 2011 Updating the record that fired the Plugin in post-sync and post-async stage

查看:172
本文介绍了crm 2011更新在后同步和后异步阶段触发插件的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在插件中,我必须更新在同步前,同步后和异步后触发插件的记录。

In a Plugin i have to update the record the plugin was fired by on pre sync, post sync, post async.

在同步前状态下,我只需更新上下文实体,例如mycontact.Attributes [ lastname] = ABC并自动保存更改的值。

In Pre-sync-state, i just have to update the Context-Entity e.g. mycontact.Attributes["lastname"] = "ABC" and the changed value is automatically saved.

在更新后,我不能这样做,因为它已经在数据库(但未提交)。我尝试使用该服务(service.update(mycontact)失败。

In Post-Update, i can not do that as its already in the Database (but not committed). My attempts to use the service (service.update(mycontact) failed.

在更新后更新记录(同步/异步)的最佳方法是什么-如果

What is the best way to Update a record in Post-Update (sync/async) - if its possible at al?!

更新其他记录没有问题,但是更新记录是由/从触发的,这是行不通的。:-(

Updating other Records is no problem, but updating record the plugin was fired by / from does not work. :-(

有什么想法吗?

问候,
尼克

推荐答案

您可以在Pre Sync,Post Sync插件或Post Async插件中更新记录。

You can update the record either in Pre Sync, Post Sync plugin or Post Async plugin.

在Pre Sync中更新记录插件,您只需要在Context实体中添加字段值,如下所示:

To update the record in Pre Sync plugin, you just need to add field value in the Context Entity as below:

Entity e = context.InputParameters["Target"] as Entity;
e["attribute_name"] = somevalue;

更新记录发布同步插件后,您需要在上下文实体中添加字段值并调用IOrganizationService的Update方法,如下所示:

To update the record in Post Sync plugin, you need to add field value in the context entity and call Update method of the IOrganizationService as below:

Entity e = context.InputParameters["Target"] as Entity;
e["attribute_name"] = somevalue;
service.Update(e);

要更新Post Async插件中的记录,您需要执行与Post Sync相同的操作

To update the record in Post Async plugin, you need to do the same thing as done for Post Sync plugin.

如果您只想更新同一记录的字段,建议使用预同步插件。这将减少在Core操作阶段之前执行此步骤的更新操作。

'Pre Sync' plugin is recommended if you just want to update the field of the same record. This will reduce an update operation as this step executes before Core operation stage.

如果您要将与EntityReference(Lookup)相同的记录设置为另一条记录,那么您将需要在Post Async插件中执行此操作。

If you want to set the same record as EntityReference (Lookup) to another record, then you will need to do this operation in Post Async plugin.

这篇关于crm 2011更新在后同步和后异步阶段触发插件的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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