Hyperlinking to a parent Custom Entity from a Search Select Advanced Field

1 minute read time.

This is a topic that has been recently covered within the forums. Since then I have been asked a few questions about this topic so I thought it was worth a separate article.

Below is the summary screen for an opportunity. This has come from a demonstration system in which little customization has been carried out.

In the screen above the foreign key (oppo_waveitemid) is of type Search Select Advanced and it provides a hyperlink to the parent wave item.

But the equivalent field for custom entities do not behave the same way.

Below is the same opportunity screen for a system that has had a project entity added. The custom project entity was added using the Advanced Customization wizard.

The new field doesn't provide a convenient hyperlink to the parent record.

Note: If a user clicks the change button and then presses CTRL+ double click upon the project field they will hyperlink to the linked project.

A hyperlink to the parent record can be added by using the create script to change the caption of the field. e.g oppo_projectid


var intRecordId = CRM.GetContextInfo("opportunity","oppo_projectid");
var strURL = CRM.URL("project/projectsummary.asp")+" &proj_projectid="+intRecordId;
var strCaptionText = "Project";
var strFullCaption = ""+strCaptionText+":";
Caption = strFullCaption;

This will add the hyperlink below

Note: This has added the lookup behaviour to the caption not the data field as that would require a different technique using client side code. That type of customization is discussed in other articles.

  • Thanks for the script sharing. Here is how i've gone at it to setup a quick launch link between a case and sage's incident manager

  • Jeff could you confirm that this piece of code is still working on the version 7.3 ? My own experience is that it is not working anymore.

    Thank you

  • Let me try that again without the script tags: And the code is...

    function setHyperLink(strASSFieldname, strCustomFilePath, strEntityName, strPrimaryKey) {

    // to see if on view mode

    if (!document.getElementById(strASSFieldname)) {

    //Get the record information

    var product = document.getElementById("_Data" + strASSFieldname);

    var productid = document.getElementById("_HIDDEN" + strASSFieldname);

    var productname = document.getElementById("_HIDDEN" + strASSFieldname + "TEXT");

    //If we have an ID field, lets create our link

    if (productid != undefined) {

    //Get the URL

    var strPath = document.URL;

    var arrayApp = strPath.split("crmtng");

    var URL = arrayApp[0];

    //Get our session ID and context

    var arrayContext = strPath.split("?");

    var strContextInfo = arrayContext[1];

    //Build our URL

    var strURL = URL + "crmtng/CustomPages/" + strCustomFilePath + "?" + strPrimaryKey + "=" + productid.value + "&" + strContextInfo + "&J=" + strCustomFilePath + "&=F=" + strEntityName;

    //Add the anchor link to our text

    var strCaptionText = productname.value;

    strFullCaption = "" + strCaptionText + "";

    product.innerHTML = strFullCaption;

    }

    }

    }

  • To expand on Lynns great work (thanks Lynn, very helpful (and of course Jeff for the original post)). I have packaged this up into a reusable function that I could include it where required. the code is:

    Usage is something like:

    setHyperLink("oppo_prodid", "MortgageProduct/MortgageProductSummary.asp", "MortgageProduct", "prod_mortgageProductID");

    Note I have hard coded our instance name (CRMTNG). Other than that should work anywhere.