2014-01-11 197 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