Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Show data in lookup field from separate entity other than primary key

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

What I am looking to do is show more data in the lookup field on the Contact form. I have a separate entity for location that I created  which has three fields: City, Province and Country.  Right now the lookup field on the Contact form only shows the city (PK) but I would like it to show the City, Province, Country from the location entity. I understand I need to use Javascript to do this I am just not sure about the code and how to get the data from the location entity to the contact form other than the city.

Any help would be greatly appreciated.

*This post is locked for comments

  • gdas Profile Picture
    gdas 50,089 on at
    RE: Show data in lookup field from separate entity other than primary key

    Hi TJE,

    Please close the thread by verifying answers.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Show data in lookup field from separate entity other than primary key

    Okay so what I ended up doing was I created 3 separate fields in the location entity: city, province, country to go along with the name (pk) field. I than created a process(workflow) that would set the name field to what was entered in the city, province and country field when it is saved. I then made the name field not visible on the form as it will be filled by the rest of the data.

    Now when searching for a location from the contact entity the city, province and country are displayed.

    Thanks for the help everyone.

  • Verified answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Show data in lookup field from separate entity other than primary key

    Hi TJE,

    You can not set multiple columns  in the lookup selected value.

    When you select Lookup field value  it's basically set   name and I'd field by default for every lookup to show the selected value and you can't change this behaviour untill and unless you fill the city name value with province and country.

    So there is only one chances that when you create the location record fill the primary key name with  name +Country+ Province  in the onchange event of country and province at the time of creating location.

    In simple words you need to save the name value by concatenating province and country text in location entity.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Show data in lookup field from separate entity other than primary key

    Here are two other solution I looked at but they only show you how to change the field name for the Id. I would like to display more information in the field.

    burnignorance.com/.../how-to-change-display-text-of-a-lookup-field-in-dynamics-crm-2011-using-javascript

    community.dynamics.com/.../136580

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Show data in lookup field from separate entity other than primary key

    Hi Goutam,

    Thanks for the suggestions. I do have that working - showing the full location once you click on the search icon in the lookup box (the actual lookup view has city, province, country). My problem is I want the box  to display the whole location without having to click the search icon.

    locpic.png

    Here is what it looks like now, I would like it to display "Winnipeg, Manitoba, Canada" instead of just "Winnipeg"

    Thanks again for the help.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Show data in lookup field from separate entity other than primary key

    Thanks for the help as I may use this in the future but this isn't exactly what I need for this. I have a list of locations saved in the Location entity, I would like to use a lookup in the contact form to lookup a saved location and display the city, province and country all in the lookup box rather that have a separate box displaying the information. Currently the location lookup box will only display the city (i.e. Winnipeg) as it is the primary key but I would like it to display Winnipeg, Manitoba, Canada (which is what the location is saved as in the location entity).

    Hope that is more clear.

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Show data in lookup field from separate entity other than primary key

    Hi TJE ,

    If I am not wrong you want to display more data in the city lookup itself. If yes then you need to just change the lookup view of location entity.

    Go to settings -> customization > customize the system/ solution -> Expand entity - > Expand location entity > views > open the lookup view > add columns Province , country .

    For more information see below references-

    [View:https://arunpotti.wordpress.com/2017/05/31/how-to-customize-lookup-views-in-crm/]

    [View:https://ledgeviewpartners.com/blog/customize-lookup-views-in-dynamics-crm/]

    Changing above you will see those data when you going to search city lookup but not in the selected lookup value.

    If you wish to display province and country field after selected the city lookup you need to go for quick view form,  You don't need to write any JavaScript. Just create a quick view form in the location entity and add the the quick view form in the contact entity.

    [View:http://www.websan.com/blog/item/720-create-d365-quick-view-forms-in-3-easy-steps]

  • Suggested answer
    Flydancer Profile Picture
    Flydancer 1,332 on at
    RE: Show data in lookup field from separate entity other than primary key

    Which CRM Version are you using? If it's an actual one you can add a quick view form to achieve your goal. See www.magnetismsolutions.com/.../how-to-add-a-quick-view-form-in-microsoft-dynamics-365

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans