locked
CRM 2013 - C# Plugin - Lookup RRS feed

  • Question

  • Hi

    Im currently using a look up form on a entity called Order, the lookup will retrieve information for a account which is its own entity

    On the account there is a lookup for currency

    I'm using the following code to get information from the first lookup

      var accountCode = ((Microsoft.Xrm.Sdk.EntityReference)(accountCodePostImage.Attributes["accountid"]));
                    var accountID = service.Retrieve(accountCode.LogicalName, accountCode.Id, new ColumnSet(true));
                    var actualID = accountID["new_accountcode"].ToString();
                    var currency = accountID["transactioncurrencyid"].ToString();

    The line

       var currency = accountID["transactioncurrencyid"].ToString();

    Is suppose to return the currency that has been selected, but all im getting returned is

    Microsoft.Xrm.Sdk.EntityReference

    Anyone know how I get the actual value that is in the lookup?

    I don't think the above code would work if modified for the second lookup as I don't have an image registered in the registration plugin tool as I don't have access to the field as im working on a different entity

    Thanks, Shaun


    S.Harrison

    Thursday, June 19, 2014 9:55 AM

Answers

  • Hi,

    The currency field is a lookup itself. So, in order to get the currency name, you'll need to use it as

    var currencyName = ((Microsoft.Xrm.Sdk.EntityReference)accountID["transactioncurrencyid"]).Name;


    Admin QuikView Solution for CRM 2013

    Thursday, June 19, 2014 10:10 AM