简体   繁体   English

Silverlight -CRM2011:货币不能为空

[英]Silverlight -CRM2011 : The Currency Cannot Be null

I use Silverlight o-data services to interact with crm 2011 from my application When I try to save the data in the entity SalesOrder as follows: 当我尝试将数据保存在实体SalesOrder中时,我使用Silverlight o数据服务与我的应用程序中的crm 2011进行交互,如下所示:

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);

}

In my function EndSaveChanges (result), I receive this error message : : « The Currency Cannot Be null ». 在函数EndSaveChanges(结果)中,我收到以下错误消息: «货币不能为空»。 I don't understand why, because my "orderHeader.TransactionCurrencyId" field is not null. 我不明白为什么,因为我的“ orderHeader.TransactionCurrencyId”字段不为空。

I assuming that all of your other Currency fields are populated? 我假设您所有其他“货币”字段都已填充?

Any chance you have another plugin that is firing as a result of yours that is throwing the exception. 您有可能因为您的插件而触发另一个引发异常的插件。 That always seems to bite me. 那似乎总是在咬我。 Try disabling all other plugins except for the one you're working on... 尝试禁用除您正在使用的插件以外的所有其他插件...

If you're still having issues, turn on crm server side tracing. 如果仍然有问题,请打开crm服务器端跟踪。 You'll get much better error information. 您将获得更好的错误信息。 Use the CRM diagnostic tool to turn on trace logging: http://crmdiagtool2011.codeplex.com 使用CRM诊断工具打开跟踪日志记录: http : //crmdiagtool2011.codeplex.com

Mostly your Guid is wrong and it's resulting in null. 通常,您的Guid是错误的,并导致null。 Make sure it's the correct GUID you are using or not. 确保这是您使用或不使用的正确GUID。 Run an advanced find against the entity and find the correct GUID. 对实体运行高级查找,然后找到正确的GUID。 It's not a good idea to hard code the GUID. 对GUID进行硬编码不是一个好主意。 If you deploy your solutions to some other org it won't work. 如果将解决方案部署到其他组织,则将无法使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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