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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Set a lookup value to open in a new window or new tab.

(0) ShareShare
ReportReport
Posted on by 200

I am assuming I will need JS for this so could someone help me develop a web resource that targets a lookup and opens the lookup record in a new widow or tab on click.

*This post is locked for comments

I have the same question (0)
  • Suggested 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]

    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/]

    After that, learn how to get field type

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

    finally, learn how to open record

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

  • whatup Profile Picture
    200 on at

    So I am not using a button I am using the actual lookup value it’s self. I am agile to target the value and open the record. I tested it by opening another lookups record using another lookups value. The only thing I can’t get working is the new window part and I followed what Microsoft recommends.

    Any ideas? I will post the code tomorrow.

  • whatup Profile Picture
    200 on at


    function openLookupNewWindow(){
        $("#customerid").children().find("span.ms-crm-Lookup-Item").click(function(){
            var options = {openInNewWindow: true};
            var type = Xrm.Page.getAttribute("ic_regardingorganizationid").getValue()[0].id;
            Xrm.Utility.openEntityForm("account", type, null, options);
        });
    }

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

    Hi,

    from the code you shared, it seems you are using unsupported code, are you sure you want to do it  that way, it could be not working after you migrate to next version in future.

  • whatup Profile Picture
    200 on at

    I will do it like this for now and possibly migrate the code to an inline button once its working. Still I am unable to open in a new window... Does my code look correct?

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

    Hi ,

    i double check my code, it is working as expected. The below is my code.

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


    }
    }
    }

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at

    Hi,

    Please chek below link:

    crmpolataydin.wordpress.com/.../crm-2013-open-entity-form-in-new-window-by-javascript

    Thanks:)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans