Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Link to Related Entities

Posted on by 245

I have Employer and Employees entities with 1:N relationship. On the Employees form, I have a lookup field for the Employer so users can click on Employer name, and CRM will take user to the Employer screen. Is there a way to add a button on the form or on the ribbon so that instead of lookup, user will click on the button named "Employer" and CRM will take user to the related Employer page?

The reason I want to do this way is because I have lot of related entities and I do not want to have several lookups on the page. It will look much better if every page have buttons like "Employer", "Loan" etc and when user click on those, CRM will display the related entity record.

Thanks.

*This post is locked for comments

  • Suggested answer
    SamCRM1 Profile Picture
    SamCRM1 245 on at
    RE: Link to Related Entities

    Thank you so much :)

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Link to Related Entities

    Hi ,

    Please follow steps -

    - If you dont have ribbon workbench , download it first. Import the solution in CRM instance.

    - Create a JS webresource where to write your JS action with below code .

    function OpenEmployerForm() {
        if (Xrm.Page.getAttribute("new_EmployerlookupFieldName").getValue() != null) {  // Replace lookup feild name
            var employerID = Xrm.Page.getAttribute("new_EmployerlookupFieldName").getValue()[0].id;// Replace lookup feild name
            var option = {};
            option["openInNewWindow"] = false;
            Xrm.Utility.openEntityForm("new_employer", employerID, null, option);// Replace entity name 
        }
    }
    

    - Create a test solution and include employee entity.

    - Open Ribbon Workbench and select the newly created solution.

    - Add button in the ribbon workbench form section.

    - Fill necessary information  for the button like name ,image etc and then add command  , in the command call JS action method by selecting JS webresource and the above JS function name.

    Hope this helps.

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Link to Related Entities

    Hi,

    You can do that, you can navigate to your parent entity by reading lookup field id, As you are using CRM 2016, you can use XrmUtility.Openform, check this: community.dynamics.com/.../xrm-utility-functions-openentityform

    You can have javascript method which can run on your ribbon button to open record

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans