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:
Privatevoid beginSave(){SalesOrder orderHeader =newSalesOrder();
orderHeader.TransactionCurrencyId=newEntityReference(){Id=newGuid("77D695B5-ACB4-E111-97BC-00155D55B216"),LogicalName="transactioncurrency"};
orderHeader.AccountId=newEntityReference(){Id=newGuid(MyClassGeneralOrder.customerId),LogicalName="account"};
orderHeader.Name="My Name";Money totalAmount =newMoney();Money totalAmountBase =newMoney();Money totalTaxe =newMoney();Money totalAmountLessFreight =newMoney();
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=newEntityReference(){Id=newGuid("03C5C4CB-EBD0-E111-8140-00155D55B216"),LogicalName="pricelevel"};
_context.AddToSalesOrderSet(orderHeader);
_context.BeginSaveChanges(SaveCallback, orderHeader);}privatevoidSaveCallback(IAsyncResult result){
_context.EndSaveChanges(result);}
In my function EndSaveChanges (result), I receive this error message : « The Currency Cannot Be null ».
I don't understand why, because my "orderHeader.TransactionCurrencyId" field is not null and in my Crm 2011 I have just one default Currency ID.
Thank you for helping me !