我尝试在添加新帐户时设置我的选项列表的选定值。我的代码是:
CrmService service = connectToCrm();
PropertyCollection Prop = new PropertyCollection();
DynamicEntity Firma = new DynamicEntity();
// set table
Firma.Name = EntityName.account.ToString();
StringProperty accountName = new StringProperty();
accountName.Name = "name";
accountName.Value = aDict["name"].ToString();
Prop.Add(accountName);
StringProperty vendorCode = new StringProperty();
vendorCode.Name = "new_bayikodu";
vendorCode.Value = aDict["new_bayikodu"].ToString();
Prop.Add(vendorCode);
StringProperty VD = new StringProperty();
VD.Name = "new_taxoffice";
VD.Value = aDict["new_taxoffice"].ToString();
Prop.Add(VD);
StringProperty VN = new StringProperty();
VN.Name = "accountnumber";
VN.Value = aDict["accountnumber"].ToString();
Prop.Add(VN);
StringProperty address = new StringProperty();
address.Name = "address1_line1";
address.Value = aDict["address1_line1"].ToString();
Prop.Add(address);
StringProperty tel = new StringProperty();
tel.Name = "telephone1";
tel.Value = aDict["telephone1"].ToString();
Prop.Add(tel);
StringProperty accountEmail = new StringProperty();
accountEmail.Name = "emailaddress1";
accountEmail.Value = aDict["emailaddress1"].ToString();
Prop.Add(accountEmail);
Firma.Properties = Prop;
Guid CustomerGuid = service.Create(Firma);
示例我想将城市选项列表设置为“istanbul” 我可以使用选项列表属性吗?
答案 0 :(得分:3)
以下是SO中提出的类似问题:Setting BusinessEntity picklist value using CRM 4.0 webservice
请注意,要在实体上设置选项列表属性,您需要知道要选择的选项列表项的值。此value属性的类型为integer。您可能需要从CRM中查看属性架构以获取此值。或者,如果要在多个组织中安装此自定义并且您认为此值可能会更改,则可能需要检索属性元数据并根据名称以编程方式确定正确的项目。 (第二种解决方案并不理想,因为选项列表'名称'可能会更新,因此会破坏您的代码。)
PicklistProperty city = new PicklistProperty();
city.Name = "new_city";
city.Value = 23; // City Picklist Value for 'istanbul';
Prop.Add(city);
答案 1 :(得分:0)
PicklistProperty city = new PicklistProperty();
city.Name = "new_city";
city.Value = new Picklist();
city.Value.Value = 23; // City Picklist Value for 'istanbul';
然后您可以使用“城市”设置您的选项列表。