使用CRM 2011中的OrganizationServiceClient无法使用手动折扣创建发票详细信息

时间:2014-01-11 13:14:16

标签: dynamics-crm-2011 invoice

我正在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);

这可能是什么问题?

1 个答案:

答案 0 :(得分:0)

尝试使用以下代码添加manualdiscountamount字段:

entityDetails.Attributes.Add(new KeyValuePairOfstringanyType() {
                                key = "manualdiscountamount",
                                value = new Money(Convert.ToDecimal(15))
                            });

因为manualdiscountamount字段属于Money类型。重新检查article