我试图在CRM 2011中创建一个实体(不是开箱即用的类型,但是CRM 4中的实体将被称为DynamicEntity ..一个用我的自定义属性)。下面的代码给了我这个错误,我不知道为什么。如果我删除new_accounttype
属性并尝试使用另一个自定义属性,则此代码将完全相同。在CRM 2011中创建实体时出错 - CRM不喜欢OptionSetValue
CRM似乎已将“OptionSetValue”设置为该键值对的值的问题。 new_accounttype是一个选择列表(或CRM 2011中的OptionSet),并且从前端拉取的值为100000003
,因此它是有效的值。
Error: A validation error occurred. The value of 'new_accounttype' on record of type 'account' is outside the valid range.
我在做什么错?
public static void CreateAccount(string accountName, string accountType)
{
//Create properties
KeyValuePairOfstringanyType[] attributes = new KeyValuePairOfstringanyType[2];
attributes[0] = new KeyValuePairOfstringanyType() { key = "name", value = accountName ?? "" };
attributes[1] = new KeyValuePairOfstringanyType() { key = "new_accounttype", value = new OptionSetValue() { Value = 100000003 } };
////Create DynamicEntity
Entity accountToCreate = new Entity();
accountToCreate.LogicalName = "account";
accountToCreate.Attributes = attributes;
try
{
service.Create(accountToCreate);
}
}
你引用Silverlight的肥皂终点? –
是/是否发布了所有内容?根据所使用的价值和名称来判断,这是一个自定义字段。 – glosrob
只是一个故障排除建议,获取具有该值的现有实体,并查看调试器或其他输出中设置的内容。如果你设置的不是系统所期待的。 – user1231231412