Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

display Look Up Record form and get the selected records by code

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to mimick Add Existing button action in an entity which is used to relate 2 other entities.

For example, let's assume in a leasing company we have cars and drivers and we are building 3-rd entity called Car Driver-

in which we hold all the relationships between those entities.

This table will mimick Many To Many relationship.

so, if we are on a car record, and we want to add car driver, I want the user to have only to choose drivers from Look Up Record form (of Drivers),

and to create the new records\relationships automatically in the code.

I would like to know if I can display Look Up Record form and get the selected records by code, and how.

Thanks a lot in advance!

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: display Look Up Record form and get the selected records by code

    What do you mean  - 'hide show the out of box N:N grid with help of a ribbon button' ?

    Is it Possible to have only the + button action in a ribbon action and hide the grid itself?

    Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: display Look Up Record form and get the selected records by code

    Hi,

    Thank you all!

    Right now I'm trying Mayank suggestion.

  • Verified answer
    unizap Profile Picture
    unizap on at
    RE: display Look Up Record form and get the selected records by code

    Hi,

    Following screenshots demonstrate what I am suggesting. 

    • Car form with 2 sub-grids (out of box N:N & Custom N:N)

    2018_2D00_05_2D00_16_5F00_14_2D00_57_2D00_33.jpg

    • Click to add drivers in 1st Grid - Look up more records

    2018_2D00_05_2D00_16_5F00_14_2D00_48_2D00_09.jpg

    • Select the drivers to associate with this car record & add.

    2018_2D00_05_2D00_16_5F00_14_2D00_48_2D00_47.jpg

    • Plugin on "Associate" message which creates new records in Custom N:N entity

    2018_2D00_05_2D00_16_5F00_14_2D00_57_2D00_33.jpg

    Please note that we can also implement a logic to hide show the out of box N:N grid with help of a ribbon button. The purpose of 1st grid is only to provide the user with the lookup dialog to select drivers only.

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: display Look Up Record form and get the selected records by code

    Hi ,

    take some pictures and show we how you configure in your environment.

  • Suggested answer
    unizap Profile Picture
    unizap on at
    RE: display Look Up Record form and get the selected records by code

    One way to do this would be to define an out of box N:N relationship between Car entity & Driver entity.

    Then add this relationship sub-grid on both forms.

    From this sub-grid you will be able to select & add multiple drivers/cars.

    Finally, write a plugin on Associate message which will create a new record in the custom N:N entity.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: display Look Up Record form and get the selected records by code

    You are suggesting to have some relationships-

    not only to relate car and driver to car driver,

    but also to relate car and driver to each other,

    so whenever car is related to driver or vice versa we will create automatically new car driver accordinglly.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: display Look Up Record form and get the selected records by code

    Hi,

    No the lookup fields are on the Car Driver entity.

    I have 3 entities - Car, Driver, Car Driver.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: display Look Up Record form and get the selected records by code

    Hi,

    I've created a sample in my environment, please check is that what you configured in your environment?

    https://youtu.be/6PVBzT3HUzQ

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: display Look Up Record form and get the selected records by code

    Hi,

    based on the statement below, you are creating driver lookup field in car, and car lookup field in driver, isnt?

    But my main issue is to create Car Drivers records automatically after the User choose Cars records (if it is on Driver, let's  say) from a lookup form.

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: display Look Up Record form and get the selected records by code

    Hi ,

    like this?

    Car

    driver.png

    Driver

    driver.png

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,494 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