Search code examples
javascriptdynamics-crmcrmdynamics-crm-2015

View Contact information from contacts lookup


I have created custom entity called "Property" that contains a Lookup field "Owner1" (“Contact" Entity). I need to display some of the contact info like (Email,Mobile,etc) when the user selects "Owner1" as read only.

My question is: Is it possible to accomplish that through javascript only?

I tried something like

Xrm.Page.getAttribute("new_owner1").getValue()[0].id

but I found that not all contact attributes are available on the client side ex:
Xrm.Page.getAttribute("new_owner1").getValue()[0].emailaddress1 //(undefined)

what is the best practice to do that?


Solution

  • You can use Quick view form to achieve this without code.

    You asked through JS only, then you have to retrieve other attributes of contact on change of lookup field using Service call. (But you said read-only?)

    This is a sample odata query you can use with OrganizationData.svc:

    var selectQuery = "/ContactSet?&$filter=ContactId eq guid'" + lookupid + "'&$select= emailaddress1,MobilePhone";
    

    Btw, you have long way to go. Read the documentation a lot & follow blogs. Read SDK thoroughly.