我正在OrganizationServiceClient
使用CRM 2011
,当我使用invoicedetail
创建manualdiscountamount
时,折扣不会显示在CRM website
中。
这是我的代码:
OrganizationServiceClient client = new OrganizationServiceClient("CustomBinding_IOrganizationService",new EndpointAddress(AuthenticationInfo.OrganizationServiceUrl))) { client.ConfigureCrmOnlineBinding(AuthenticationInfo.OrganizationPolicy.IssuerUri);
client.Token = AuthenticationInfo.OrganizationToken;
Entity entityDetails = = new Entity();
entityDetails.LogicalName = "invoicedetail";
entityDetails.Attributes = new AttributeCollection();
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "productid",
value =
new EntityReference() {
LogicalName = "product",
Id = Guid.Parse("Some Product Id")
}
});
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "uomid",
value =
new EntityReference() {
LogicalName = "uom",
Id = Guid.Parse("33B75DB8-8771-4B5A-875F-810CC0732C0C")
}
});
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "invoiceid",
value = new EntityReference() {LogicalName = "invoice", Id = Guid.Parse("Some Invoice Id")}
});
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "quantity",
value = 1
});
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "createdon",
value = DateTime.Now
});
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "manualdiscountamount",
value = 15
});
invoiceDetailsId = client.Create(entityDetails);
这可能是什么问题?
答案 0 :(得分:0)
尝试使用以下代码添加manualdiscountamount字段:
entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
key = "manualdiscountamount",
value = new Money(Convert.ToDecimal(15))
});
因为manualdiscountamount字段属于Money类型。重新检查article