怎样创建一个dynamics 365 CRM online plugin (二)

Golden Rules

1. Platform only passes Entity attributes to Plugin that has change of data.

2. If the user does not enter any value into attribute, the attribute is not avaible in AttributeCollection of Entity.

3. Always check if attribute is present in the collection before you use it.

 介于上面三条rules, 我们来改动一下上篇博客中的问题.

如果用户firstName 没有输入, 将会以下面截图的内容一样报错. 

为了避免这个问题, 我们需要对代码做一系列的修改.

怎样创建一个dynamics 365 CRM online plugin

扫描二维码关注公众号,回复: 5799243 查看本文章

怎样创建一个dynamics 365 CRM online plugin

我们要在代码上面做null check

 怎样创建一个dynamics 365 CRM online plugin

在register tool 上选中之前创建的assembly, 并且勾选update,做更新.

怎样创建一个dynamics 365 CRM online plugin

我们这次再测试一下创建新的contact. 

怎样创建一个dynamics 365 CRM online plugin

怎样创建一个dynamics 365 CRM online plugin

这时候可能有人会问到, last name 为什么不检测呢? lastName 是必填项, 不必在代码中再做检查.

猜你喜欢

转载自www.cnblogs.com/TheMiao/p/10663088.html