Dynamics CRM: 插件输入参数(InputParameters)中的Target属性

对于插件中不同的消息, 比如: 创建(Create), 更新(Update), 分配(Assign)等, 我们通过Target属性所获取的东西是不一样的.

以创建(Create)消息为例:

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
    context.InputParameters["Target"] is Entity)
{
    // Obtain the target entity from the input parameters.
    Entity entity = (Entity)context.InputParameters["Target"];
}

这里的entity变量是创建一条记录时所录入的字段, 可以使用contain方法来判断是否在创建时录入了某个字段, 如果创建时没有填写这个字段,那时用Contain方法返回的就是false

if (entity.Contains("<字段>"))
{
    // some logic
}

  • 对于更新(Update)消息也是如此, 使用Target属性所获取的实体里面包含的字段, 也只是更新的字段, 没有更新的字段在Contain方法中返回的会是false.

对于其他消息, 我会在以后进行更新.

参考链接:

Understand the data context passed to a plug-in | Microsoft Docsicon-default.png?t=LA92https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg309673(v=crm.8)?redirectedfrom=MSDN

CreateRequest Class (Microsoft.Xrm.Sdk.Messages) | Microsoft Docsicon-default.png?t=LA92https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg327591(v=crm.8)

UpdateRequest Class (Microsoft.Xrm.Sdk.Messages) | Microsoft Docsicon-default.png?t=LA92https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg327638(v=crm.8)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Stone-hdj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值