Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Open a lookup field in new window

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

i have a requirement to open the lookup value in new window.

Requirements : Must be supported.

*This post is locked for comments

  • SEMAJ Profile Picture
    10 on at
    RE: Open a lookup field in new window

    Do you know if there is a way to add the onclick functionality to the actual field rather than a ribbon button?

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Open a lookup field in new window

    Hi,

    I share you my code. Copy and paste it to your JS file.

    function SetHyperlink()

    {

       var currentControl = Xrm.Page.ui.getCurrentControl();

      if (currentControl == null)

      {

          alert("No controls currently have focus.");

      }

    else

    {

     if (currentControl.getControlType() == "lookup")

     {

         var controlname = currentControl.getName();

         var controlvalue = new Array();

         var EntityType ="";

     var id= "";

     controlvalue = Xrm.Page.getAttribute(controlname).getValue();

       if(controlvalue !=null)

    {

        EntityType = controlvalue[0].entityType;

        id         = controlvalue[0].id;

       var windowOptions = {openInNewWindow: true};

           Xrm.Utility.openEntityForm(EntityType,id,null,windowOptions);

    }

    else

    {

     alert("Lookup field does not contain value, Please provide a value");

    }

      }

     }

     }

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Open a lookup field in new window

    Hi

    first learn how to create a button and associate to a JS inside a form.

    [View:http://himbap.com/blog/?p=1473:750:50]

    Next, learn how to get lookup id and entity name

    [View:https://arunpotti.wordpress.com/2014/12/19/get-lookup-id-text-entityname-in-crm-using-javascript/:750:50]

    After that, learn how to get field type

    [View:https://msdn.microsoft.com/en-us/library/gg334266.aspx#:750:50]

    finally, learn how to open record

    [View:https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenEntityForm:750:50]

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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans