简体   繁体   English

Dynamics CRM如何带来实体记录的当前ID

[英]Dynamics CRM how to bring the current Id of a entity record

I'm new in the community, I'm strugging with a plugin of a form, where I need to get all the values of that form, in order to achive this I created a preOperation Update Plugin. 我是社区的新手,我在与一个表单插件苦苦挣扎,在其中我需要获取该表单的所有值,以实现此目的,我创建了preOperation Update Plugin。 My plugin works perfectly only if I modify the fields inside that form. 仅当我修改该表单中的字段时,我的插件才能完美运行。 However, a normal user (I'm an admin) cannot modify any value of the form. 但是,普通用户(我是管理员)无法修改表单的任何值。 I read that I can use the method 我读到可以使用该方法

service.Retrieve(string entityName, Guid id, ColumnSet columnSet);

My question is how can I get the Guid id of the current record? 我的问题是如何获取当前记录的Guid ID? Sorry if it is to obvious but I'm new in Dynamics CRM, I appreciate any help you can give me. 抱歉,虽然很明显,但是我是Dynamics CRM的新手,非常感谢您能为我提供的任何帮助。

As your plugin is registered at pre-operation level, the record would not have been written to the database yet. 由于您的插件是在预操作级别注册的,因此该记录尚未写入数据库。

You will have to use the pre-entity image that you have registered to access the attributes (form values). 您将必须使用注册的实体前图像来访问属性(表单值)。

var pluginExecutionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var entity = pluginExecutionContext.PreEntityImages["ImageName"]; //the name that you have registered your image with
//iterate through all the attributes 
foreach (var attribute in entity.Attributes)
{
  //access the attribute values
  var attributeValue = attribute.Value;  
}

If you dont want to use pre/post image of the entity, you can retrieve the record as you mentioned in your question. 如果您不想使用实体的前后图像,则可以按照问题中提到的方式检索记录。 Getting id of the current record is easy if your plugin is registered on update message. 如果您的插件在更新消息中注册,则获取当前记录的ID很容易。

Entity entity = (Entity)context.InputParameters["Target"];
Guid recordID = entity.Id;

Also have a look at this. 也看看这个。

https://community.dynamics.com/crm/b/crminogic/archive/2010/07/26/pre-image-38-post-image-explained-33 https://community.dynamics.com/crm/b/crminogic/archive/2010/07/26/pre-image-38-post-image-explained-33

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用RetrieveMultiple消息中的Dynamics CRM插件获取当前的实体详细信息? - How to get current Entity detail using Dynamics CRM plugins in RetrieveMultiple message? Dynamics CRM 2016 c#使用尚不存在的实体的ID - Dynamics CRM 2016 c# use id of not yet existing entity 如何在 Dynamics CRM 2016 中使用 DiscoveryService 获取实体中的项目列表? - How to get list of items in an entity using DiscoveryService in Dynamics CRM 2016? 如何在 MS Dynamics CRM 中获取帐户实体的关联潜在客户记录 - How to fetch the associated Lead Records for an account entity in MS Dynamics CRM 如何通过API在CRM Dynamics中创建自定义实体本身 - How to create custom entity itself in CRM Dynamics via API 如何使用Web服务在Dynamics CRM 4中删除实体链接 - How to delete entity link in Dynamics CRM 4 using webservices 如何将国家/地区数据插入MS Dynamics CRM Lead实体 - How to insert Country data to the MS Dynamics CRM Lead entity 如何在服务器端的MS Dynamics CRM中获得当前的用户特权 - How to get current user privileges in MS Dynamics CRM on server side 如何使用CRM Dynamics 2013/2015中的插件用相关实体更新CRM中的实体 - How to update an Entity in CRM with a related Entity using a plug-in in CRM Dynamics 2013/2015 如何使用Selenium打开CRM实体记录? - How to open CRM entity record with Selenium?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM