检索“两个选项”。 CRM 2011中插件上的字段值 [英] Retrieving "two option" field value on the plugin in CRM 2011
问题描述
我正在尝试根据帐户表单中的两个选项字段来更新子联系人。如果两个选项字段设置为是,我会将所有子联系人都更新为父帐户的更新地址。
我尝试使用以下代码检索值:
Am trying to update child contacts based on a "Two Options" field in the account form. I update all child contacts to the updated address of parent account if the "Two Option" field is set to "Yes". I try to retrieve the value using the following code,
bool? updateContactsValue
= entity.GetAttributeValue<bool?>("abc_yesNoField");
if (updateContactsValue)
{
String[] details = new string[7];
String telephoneNum = String.Empty, ... , country = String.Empty;
telephoneNum = entity.GetAttributeValue<String>("telephone1");
details[0] = telephoneNum;
...
UpdateContact(service, entity.Id, details);
}
但是我发现即使选择的选项也不会更新地址字段是是的。我在这里错过了什么吗?
But i find that the address fields are not being updated even if the selected option is "Yes". Am i missing something here?
大家好,
我已将代码修改如下
Hi all, I have modified the code to as follows
bool? updateContactsValue=null;
updateContactsValue = entity.GetAttributeValue<bool?> ("abc_yesNoField").GetValueOrDefault();
throw new Exception( "My custom Exception"+" "+entity.GetAttributeValue<bool?>("abc_yesNoField").GetValueOrDefault().ToString());
即使我选择是,系统也会抛出假。
The system throws "false" even if I had chosen "Yes".
推荐答案
可能出现问题是由于您使用的是 Scheema Name (示意图名称),即大小写混合。 abc_yesNoField 不能是属性bcoz的名称,它使用大小写混合。
应该是LowerCase,例如 abc_yesnofield
May be problem is due to that you are using Scheema Name i.e mixed case. abc_yesNoField cannot be Name of attribute bcoz it uses mixed case. It should be LowerCase like abc_yesnofield
bool? updateContactsValue= entity.GetAttributeValue<bool?>("abc_yesnofield");
始终使用属性的逻辑名称,即名称 >(总是小写)在:
1. Xrm
2. c#代码后期绑定
Always Use Logical Name of attribute i.e Name (Always lowercase) in:
1. Xrm
2. c# code late bind
使用 Scheema属性的名称,(混合大小写或驼峰式)位于:
1. REST / oData / JSON对象模型
2. c#早期绑定类(LINQ)
Use Scheema Name of attribute i.e (mixed case or camel casing) in:
1. REST/oData/JSON object model
2. c# early bound classes (LINQ)
这篇关于检索“两个选项”。 CRM 2011中插件上的字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!