【发布时间】:2013-03-28 21:21:40
【问题描述】:
我正在尝试根据帐户表单中的“两个选项”字段更新子联系人。如果“两个选项”字段设置为“是”,我会将所有子联系人更新为父帐户的更新地址。 我尝试使用以下代码检索值,
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);
}
但我发现即使选择的选项是“是”,地址字段也没有更新。我在这里错过了什么吗?
大家好, 我已将代码修改为如下
bool? updateContactsValue=null;
updateContactsValue = entity.GetAttributeValue<bool?> ("abc_yesNoField").GetValueOrDefault();
throw new Exception( "My custom Exception"+" "+entity.GetAttributeValue<bool?>("abc_yesNoField").GetValueOrDefault().ToString());
即使我选择了“是”,系统也会抛出“假”。
【问题讨论】:
-
我冒昧地大幅缩减您的代码,以说明问题的基本部分。希望你喜欢。
-
最好做一个简单的 var value = entity["abc_yesNoField"];要检索真实的字段值,请尝试使用此变量抛出 execption
-
我敢打赌,如果您故意拼错字段名称,您会得到相同的行为。请检查一下。另外,请您更好地对示例进行换行吗?
-
嗨,我确实尽我所能来格式化我的问题。谢谢 Guido,我确实按照你的想法抛出异常来看看我得到了什么价值,即使“是”被选中。
标签: dynamics-crm-2011 crm