简体   繁体   中英

null Amount value salesorderdetail on crm 2011-Silverlight

I'm trying to insert data on SalesOrderDetail entity, everything works fine, except for the Amount field which remains null. I don't get any error message. Here is an example of my code :

private void beginCreateSalesOrderDetail()
{
    SalesOrderDetail orderDetail = new SalesOrderDetail();
    orderDetail.SalesOrderId = new EntityReference() 
    { 
       Id = id, 
       LogicalName = "salesorder" 
    };
    orderDetail.Quantity = element.QuantityOnHand;
    orderDetail.ProductId = new EntityReference() 
    { 
        Id = element.ProductId, 
        LogicalName = "product" 
    };
    orderDetail.UoMId = new EntityReference() 
    { 
        Id = new Guid("8DDD2AFB-73CF-E111-8140-00155D55B216"),        
        LogicalName = "uom" 
    };
    orderDetail.TransactionCurrencyId = new EntityReference() 
    { 
        Id = new Guid("77D695B5-ACB4-E111-97BC-00155D55B216"), 
        LogicalName = "transactioncurrency" 
    };

    Money Taxe = new Money(); 
    Money Amount = new Money();
    Taxe.Value = Convert.ToDecimal(element.totalCharges);
    Amount.Value = Convert.ToDecimal(InvoiceTotal);
    orderDetail.Tax = Taxe;
    orderDetail.BaseAmount = Amount;
    orderDetail.PricePerUnit = element.Price;
    orderDetail.Description = element.PDesc;
   _context.AddToSalesOrderDetailSet(orderDetail);
 _context.BeginSaveChanges(EndCreateSalesOrderDetail, orderDetail);

}



private void EndCreateSalesOrderDetail(IAsyncResult result)
  {

     try
     {
       _context.EndSaveChanges(result);
     }
            catch (Exception ex)
            {
            }

   }    

Please note that only the amount which remains null

I get the solution. Actually, there is a restrictions in crm 2011 to calcul the amounts of products, We have to create a Price List, and associate each product in the list. Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM