web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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]

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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");

    }

      }

     }

     }

  • SEMAJ Profile Picture
    10 on at

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

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans