[英]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.