Silverlight -CRM2011:货币不能为空

本文关键字:不能 货币 -CRM2011 Silverlight | 更新日期: 2023-09-27 17:49:24

我使用Silverlight o-data服务从我的应用程序与crm 2011进行交互当我尝试在实体SalesOrder中保存数据时,如下所示:

Private void beginSave()
{
SalesOrder orderHeader = new SalesOrder();
orderHeader.TransactionCurrencyId = new EntityReference(){ Id = new Guid("77D695B5-ACB4-E111-97BC-00155D55B216"), LogicalName="transactioncurrency" };
orderHeader.AccountId = new EntityReference() { Id = new Guid(MyClassGeneralOrder.customerId), LogicalName = "account" };
orderHeader.Name = "My Name";
Money totalAmount = new Money(); Money totalAmountBase = new Money(); 
Money totalTaxe = new Money(); Money totalAmountLessFreight = new Money();
totalAmount.Value = (decimal)MyClassGeneralOrder.InvoiceTotal;
totalAmountBase.Value = (decimal)MyClassGeneralOrder.totalRetail;
totalTaxe.Value = (decimal)MyClassGeneralOrder.totalCharges;
totalAmountLessFreight.Value = (decimal)MyClassGeneralOrder.totalNet;
orderHeader.TotalAmount = totalAmount;
orderHeader.TotalAmount_Base = totalAmountBase;
orderHeader.TotalTax = totalTaxe;
orderHeader.TotalAmountLessFreight = totalAmountLessFreight;
orderHeader.Description = element.Name;
orderHeader.PriceLevelId = new EntityReference() { Id = new Guid("03C5C4CB-EBD0-E111-8140-00155D55B216"), LogicalName="pricelevel" };
_context.AddToSalesOrderSet(orderHeader);
_context.BeginSaveChanges(SaveCallback, orderHeader);
}

private void SaveCallback(IAsyncResult result)
{
_context.EndSaveChanges(result);
}

在我的函数EndSaveChanges (result)中,我收到这个错误消息::«The Currency Cannot Be null»。我不明白为什么,因为我的"orderHeader。TransactionCurrencyId"字段不为空

Silverlight -CRM2011:货币不能为空

我假设所有其他货币字段都已填充?

你是否有可能有另一个插件正在触发,因为你的插件正在抛出异常。这似乎总是让我难受。尝试禁用所有其他插件,除了你正在工作的那个…

如果你仍然有问题,打开crm服务器端跟踪。你会得到更好的错误信息。使用CRM诊断工具打开跟踪日志记录:http://crmdiagtool2011.codeplex.com

大多数情况下你的Guid是错误的,它导致null。确保您使用的是正确的GUID。对实体运行高级查找并找到正确的GUID。硬编码GUID并不是一个好主意。如果你把你的解决方案部署到其他组织,它将不起作用。