Make Hyperlink dinamically using window.location.origin

Sergio Garrido
edited March 15 in Analytics #1


I'm using Analytics Designer to make reports into D2 application.

My organization has several environments as DEV, TEST, QA… my question is below.

I have a table with a Data item that is linked to hyperlink URI as → "http://mydevD2/D2?…"

I'm trying to change the literal “mydevD2” dinamically using a script onCreate handler in the data Item as:

this.action.setHyperlink("http://" + window.location.origin + "/D2…, "_blank");

Seems that window.location.origin (DOM)) is not accessible from here. Anyone can suggest how it could be implemented?




  • Hello,
    Finally i found a workoaround after lot of trial and error. Below you can found my solution.
    In a table cell I add a Text Item to script following lines:


    environment = window.location.origin + "/D2?docbase=****&locateId=" + "<VALUE-OF>row["r_object_id"]</VALUE-OF>";

    var getWebsite = document.getElementById("<VALUE-OF>row["r_object_id"]</VALUE-OF>");

    getWebsite.innerHTML = '<a href="' + environment + '#d2" target="_blank" ><VALUE-OF>row["object_name"]</VALUE-OF></a>';


    <span id="row["r_object_id"]">

    Environment is a string that contains url using origin property + literal + the r_object_id value from Data Item.

    Then I get the span item in HTML that was created and taked using the value of r_object_id to be unique.

    Finally script inner HTML with tag and the right url for each environment.