locked
Need help with retrieving an EntityReference from CRM 2011 Online using WCF RRS feed

  • Question

  • User-241612745 posted

    Below is the information I have so far and where I am running into my problem.  After I have authenicated with CRM, I retrieve all records from an entity called product from CRM.  Below is the cutdown code I use to do this:

    'Grab information from Entity in CRM
     Dim Prods As New QueryExpression("product")
     Dim Cols() As String = {"productid", "productnumber", "tci_strength", "name", "tci_maxcoarse", "tci_mtype", "tci_prodcat", "new_location", "new_slumprange", "new_bu", "tci_isspec", "tci_opportunity", "tci_plantno", "pricelevelid", "price", "quantitydecimal", "standardcost", "currentcost", "defaultuomscheduleid", "defaultuomid", "description"}
    Prods.ColumnSet = New ColumnSet(Cols)
    Dim ProductsList = service.RetrieveMultiple(Prods)

    After I have "grabbed" all information, for a normal field I use the following to grab the value from a specific field in the record:

    Dim productid As String = ProductsList(intcnt).Attributes("productid").ToString

    This works great until I get to a lookup field (EntityReference), for example tci_mtype is a lookup field so if I do the following:

    mtype = ProductsList(intcnt).Attributes("tci_mtype").ToString

    mtype return value is Microsoft.Xrm.Sdk.EntityReference

    BTW, mtype is declared as follows: Dim mtype As String

    I hope this explains my issue and Hope someone can help :)


     

    Tuesday, January 22, 2013 4:11 PM

All replies

  • User-1000095884 posted

    This works great until I get to a lookup field (EntityReference), for example tci_mtype is a lookup field so if I do the following:

    Hi,

    Is there any error message? It seems the method is working properly, you may compare the definition of those fields to find some clue.

    Best Regards.

    Thursday, January 24, 2013 12:44 AM
  • User-241612745 posted

    No there is no error message.  What happens is it returns "Microsoft.Xrm.Sdk.EntityReference" instead of the actual value.  My thought is that there must be another way to get the value from an lookup field or something I am missing in my call.

    Thursday, January 24, 2013 11:43 AM