2014-01-11 241 views
0

我使用OrganizationServiceClientCRM 2011创建使用OrganizationServiceClient手动折扣发票明细,当我创建一个invoicedetailmanualdiscountamount,折扣不会出现在CRM website。 这里是我的代码:不能在2011年CRM

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

尝试使用下面的代码添加manualdiscountamount领域:

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

因为manualdiscountamount字段是货币类型。重新检查以下article

+0

它的工作,解决了我的问题。谢谢。 – Saied