Search code examples
linqdynamics-crm

How to retrieve both value & currency type from currency type attribute


In MS Dynamics CRM 2013 I am trying to get the value & currency type from a currency type attribute using LINQ.

By this code I can only get the value.

actualvalue = (Money)opportunity.GetAttributeValue("actualvalue")

Can anyone suggest how to get the currency associated with this attribute, I need to use LINQ only.


Solution

  • The currency is stored inside the transactioncurrencyid field. It's a lookup so by code is an EntityReference.

    var currencyRef = (EntityReference)opportunity.GetAttributeValue("transactioncurrencyid");
    

    after you can retrieve the currency details using the Id property (so will be like currencyRef.Id)