Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. At the very top of the script, define the kind of link type you would like to hide.

    Code Block
    string [] issueLinkTypeName = {"Relates"};

  2. Next add a basic webhook. For detailed information on SIL Webhooks, see this documentation on Webhooks configuration.

    Code Block
    WebhookPayload httpRequestPayload = getWebhookPayload();
    string httpMethod = httpRequestPayload.httpMethod;
    string httpPayload = httpRequestPayload.payload;
    WebhookParam[] httpQueryParams = httpRequestPayload.queryParams;
    // string firstQueryParamName = httpQueryParams[0].name;
    string issueKey = httpQueryParams[0].values[0];

  3. Next, structure your basic JSON response by adding link data to those links you want to hide. The idea here is to return alternating values of the issue id (link.id)and link id (link.issue.id). For more details on available variables, see this documentation on predefined structure types for JIssueLink.

    Code Block
    string [] result;
    JIssueLink [] links = getIssueLinksDetail(issueKey);
    for (JIssueLink link in links) {
        if (arrayElementExists(issueLinkTypeName, link.name)) {
            result += link.id;
            result += link.issue.id;
        }
    }
    result = replace(result, "|", ",");
    string json = "{\"linkData\":";
    json += "[";
    json += result;
    json += "]}";
    runnerLog(json);

  4. Lastly, append the json data to the response and respond.

    Code Block
    appendToWebhookResponse(json);
    return true, 200;
  1. Use Live Fields to call the JavaScript file using lfExecuteJS().

    Code Block
    lfExecuteJS("hideLinks.js");

  2. In “hideLinks.js”, use the attr() jQuery function to get the issue context for the page.

    Code Block
    var issueKey =  AJS.$("meta[name='ajs-issue-key']").attr("content");

  3. Next, add the ajax call. The following script calls the webhook we created and then uses the data (issue and link ids) to hide the desired links using the hide() function.

    Code Block
    AJS.$.ajax({
        url: "http://<BASE_URL>/rest/keplerrominfo/refapp/latest/webhooks/hideLinks/run?key=" + issueKey
    }).then(function(data) {
        var linkData = data.linkData;
        for ( var i = 0, l = linkData.length; i < l; i=i+2 ) {
            AJS.$("#internal-" + linkData[ i + 1 ] + "_" + linkData[ i ]).hide();
            // console.log(linkData[ i ]);
            // console.log(linkData[ i + 1 ]);
            // console.log("#internal-" + linkData[ i + 1 ] + "_" + linkData[ i ]);
            // console.log("-----------------------");
        }
    });

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@135a7
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "PKB"
labelskb-how-to-article

...